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.

Renaming a python file in the file explorer causes an error

See original GitHub issue

Description

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:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jitseniesencommented, Jan 31, 2020

File Explorer, in particular line 904-908

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:

  1. Make a directory with files foo and foobar (the important thing is that the first name is a prefix of the second name).
  2. Open both files in the editor.
  3. In the file explorer, rename foo to ham
  4. Note that in the editor, the tab foo is also renamed to ham (as expected). However, the tab foobar is erroneously renamed to hambar (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.

1reaction
goanpecacommented, Jan 20, 2020

Will do!

Read more comments on GitHub >

github_iconTop 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 >

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