question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding applications to file associations is broken on Windows due to unescaped backslashes

See original GitHub issue

Description

What steps will reproduce the problem?

  1. From a clean config, open the File Associations tab of the Files prefs pane
  2. Add any extension (e.g. .txt) to enable the “add” option for external programs
  3. Click the add button, and the resulting error appears

I haven’t investigated the relevant code thoroughly, but it appears to be due to unescaped backslashes in Windows file paths combined with use of eval. I’d suggest simply using standard forward slashes instead (using replace to convert them before parsing if necessary) since they are equally accepted on Windows as backslashes.

Also, even after I dismiss the error, my cursor remains stuck in the “hourglass” mode that was triggered with the failed launch of the file open dialog.

Traceback

  File "C:\Miniconda3\envs\spyder-4\lib\site-packages\spyder\plugins\explorer\widgets\fileassociations.py", line 496, in add_application
    self._dlg_applications = ApplicationsDialog(self)
  File "C:\Miniconda3\envs\spyder-4\lib\site-packages\spyder\plugins\explorer\widgets\fileassociations.py", line 145, in __init__
    self.setup()
  File "C:\Miniconda3\envs\spyder-4\lib\site-packages\spyder\plugins\explorer\widgets\fileassociations.py", line 152, in setup
    apps = get_installed_applications()
  File "C:\Miniconda3\envs\spyder-4\lib\site-packages\spyder\utils\programs.py", line 493, in get_installed_applications
    apps = _get_win_applications()
  File "C:\Miniconda3\envs\spyder-4\lib\site-packages\spyder\utils\programs.py", line 362, in _get_win_applications
    expanded_fpath = literal_eval(expanded_fpath)
  File "C:\Miniconda3\envs\spyder-4\lib\ast.py", line 46, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "C:\Miniconda3\envs\spyder-4\lib\ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    c:\program files (x86)\malwarebytes' anti-malware\mbam.exe
     ^
SyntaxError: invalid syntax

Versions

  • Spyder version: 4.0.0rc1
  • Python version: 3.7.5
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 8.1

Dependencies

cloudpickle >=0.5.0          :  0.7.0 (OK)
pygments >=2.0               :  2.3.1 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.4.0 (OK)
sphinx >=0.6.6               :  1.8.4 (OK)
pylint >=0.25                :  2.2.2 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  17.1.2 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.8.0 (OK)
spyder_kernels >=1.7.0;<2.0.0:  1.7.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.3 (OK)
cython >=0.21                :  0.29.4 (OK)
IPython >=4.0                :  7.2.0 (OK)
matplotlib >=2.0.0           :  3.0.2 (OK)
pandas >=0.13.1              :  0.24.2 (OK)
numpy >=1.7                  :  1.15.4 (OK)
scipy >=0.17.0               :  1.2.0 (OK)
pyls >=0.29.3;<0.30.0        :  0.29.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
CAM-Gerlachcommented, Nov 11, 2019

@ccordoba12 Sure, I’ll add it to my list. As you say its not at all critical and it should be a quick fix and test for me to do so I’ll try to get to it perhaps after the Spyder 4.0 release. Thanks.

1reaction
ccordoba12commented, Nov 11, 2019

If you found a fix, please submit a pull request for that, along with tests. If not, we’ll try to fix that when more important things are solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File Associations Broken - Microsoft Community
I have tried to change the file association but Word does not show up as an option. When I select "Look for another...
Read more >
How to set the default program for opening files without an ...
Follow hasnj's solution: First open an elevated command window and type assoc . · Open regedit and navigate to. HKEY_CURRENT_USER\Software\ ...
Read more >
Efficiently convert backslash to forward slash in R
Navigate to file path in explorer. · If copying a file path then: Shift + Right click on file, then click Copy as...
Read more >
Extra backslash's in file path - Google Groups
Hi, I have an issue where since upgrading to Wazuh 3.11.3 from 3.10 where eventchannel fields from the windows security logs that have...
Read more >
How to fix broken file type associations for Creative Cloud apps
The file type is not associated with the Creative Cloud app anymore. For example, a .PSD doesn't open with Photoshop. (Windows) Opening the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found