Adding applications to file associations is broken on Windows due to unescaped backslashes
See original GitHub issueDescription
What steps will reproduce the problem?
- From a clean config, open the File Associations tab of the Files prefs pane
- Add any extension (e.g. .txt) to enable the “add” option for external programs
- 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:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
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.