spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.37k stars 1.62k forks source link

IndexError: list index out of range when saving python file #5996

Open dufengit opened 6 years ago

dufengit commented 6 years ago

Description

What steps will reproduce the problem?

  1. save file, choose file type as python files

What is the expected output? What do you see instead?

Please provide any additional information below

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor.py", line 2392, in run_file self.re_run_file() File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor.py", line 2412, in re_run_file self.save_all() File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor.py", line 2000, in save_all self.get_current_editorstack().save_all() File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\widgets\editor.py", line 1689, in save_all if self.data[index].editor.document().isModified(): IndexError: list index out of range

Version and main components

Dependencies


pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
numpy >=1.7      :  1.13.3 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.10.5 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26.1 (OK)
qt
CAM-Gerlach commented 6 years ago

Thanks for reporting. Not sure we've seen this specific problem before, but we'll probably need more information about the circumstances in which this error occurred in order to fix it—was this the first time you tried saving a file? Does it only occur saving a particular file, or in a particular location? Did you try restarting Spyder, or saving somewhere else? Anything special about your system or environment?

Please describe step by step how you got this error so we can reproduce it in our side. If we don't hear from you, we'll have to close this issue in a week from now.

In the meantime, if you're still having this issue, you can try spyder --reset from the Anaconda prompt and restarting Spyder to hopefully fix it. Best of luck!

CAM-Gerlach commented 6 years ago

Closed due to lack of response, sorry. If you do end up seeing this and have more to add isolating the problem, then feel free to reopen. Thanks.

CAM-Gerlach commented 6 years ago

Re-opened to serve as the canonical reference for this issue, per discussion in #7045

CAM-Gerlach commented 5 years ago

For the record, I got a similar thought not identical error when doing the "close all to right" command when one of the documents have not been saved and one had been removed externally in the system file manager. Unsure if reproducible at the moment:

  File "C:\Anaconda3\lib\site-packages\spyder\widgets\editor.py", line 1470, in close_all_but_this
    self.close_all_right()
  File "C:\Anaconda3\lib\site-packages\spyder\widgets\editor.py", line 1466, in close_all_right
    self.close_file(num+1)
  File "C:\Anaconda3\lib\site-packages\spyder\widgets\editor.py", line 1416, in close_file
    is_ok = force or self.save_if_changed(cancelable=True, index=index)
  File "C:\Anaconda3\lib\site-packages\spyder\widgets\editor.py", line 1514, in save_if_changed
    if self.data[index].editor.document().isModified():
IndexError: list index out of range
ccordoba12 commented 5 years ago

I was unable to reproduce this, sorry.