Renaming a python file in the file explorer causes an error
See original GitHub issueDescription
What steps will reproduce the problem?
Had a “mobilenetv2.py” file. Renamed it via rightclick rename procedure. Typed new file name as “MobileNetV2.py”. Spyder asks “do you want to rename and replace the file”. Accepted --> Crash --> Send the bug–> Profit!
Traceback
File "C:\Users\Tulpar\Anaconda3\lib\site-packages\spyder\plugins\editor\plugin.py", line 2108, in renamed
filename, to_text_string(dest))
File "C:\Users\Tulpar\Anaconda3\lib\site-packages\spyder\plugins\editor\utils\autosave.py", line 385, in file_renamed
old_hash = self.file_hashes[old_name]
KeyError: 'C:\\ferfiles\\mobilenetv2.py'
Versions
- Spyder version: 4.0.1
- Python version: 3.7.3
- Qt version: 5.9.6
- PyQt5 version: 5.9.2
- Operating System: Windows 10
Dependencies
atomicwrites >=1.2.0 : 1.3.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
cloudpickle >=0.5.0 : 1.2.2 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.11.1 (OK)
jedi =0.14.1 : 0.14.1 (OK)
nbconvert >=4.0 : 5.6.1 (OK)
numpydoc >=0.6.0 : 0.9.2 (OK)
pexpect >=4.4.0 : 4.7.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=0.3 : 5.6.7 (OK)
pygments >=2.0 : 2.5.2 (OK)
pylint >=0.25 : 2.4.4 (OK)
pyls >=0.31.2;<0.32.0 : 0.31.2 (OK)
zmq >=17 : 18.1.0 (OK)
qdarkstyle >=2.7 : 2.7 (OK)
qtawesome >=0.5.7 : 0.6.0 (OK)
qtconsole >=4.6.0 : 4.6.0 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.8.3 (OK)
sphinx >=0.6.6 : 2.3.1 (OK)
spyder_kernels >=1.8.1;<2.0.0: 1.8.1 (OK)
watchdog : None (OK)
cython >=0.21 : 0.29.14 (OK)
matplotlib >=2.0.0 : 3.1.1 (OK)
numpy >=1.7 : 1.17.4 (OK)
pandas >=0.13.1 : 0.25.3 (OK)
scipy >=0.17.0 : 1.3.2 (OK)
sympy >=0.7.3 : 1.5 (OK)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Python error when renaming files in windows - Stack Overflow
Probably your rename is failing. Try adding some debug print to your code and see, when exactly it is failing. Before renaming add...
Read more >Unable to Rename a File in Windows 10? 8 Ways to Fix It
Unable to Rename a File in Windows 10? 8 Ways to Fix It ; Navigate to the folder containing the files you can't...
Read more >Can't find the specified file when trying to rename a file or folder
If you cannot rename a file and get Can't find the specified file error while renaming a file or folder, here is how...
Read more >Files do not open in Excel or "File Not Found" occurs when ...
If you are trying to open the file from your list of most recently used files on the File menu, make sure that...
Read more >Automate Renaming and Organizing Files with Python
Learn to rename and automate your file organization with Python! ... Rename files based on patterns, and; Organize files into logical ...
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
After looking at it in more depth, I am quite certain that those lines need to be changed because I discovered a user-visible bug which can be reproduced as follows:
foo
andfoobar
(the important thing is that the first name is a prefix of the second name).foo
toham
foo
is also renamed toham
(as expected). However, the tabfoobar
is erroneously renamed tohambar
(which leads the editor to complain that that file does not exist).I am preparing a PR to fix this. The fix makes the issue originally reported here much more prominent, so I will also include a fix for that.
Will do!