IndexError when saving file and auto-formatting is on
See original GitHub issueDescription
What steps will reproduce the problem?
list = [‘blah1’, ‘blah2’] print(sorted(list)) Issue with saving file
Traceback
File "C:\Users\Andy\AppData\Local\Programs\Spyder\pkgs\spyder\plugins\editor\widgets\editor.py", line 2093, in _save_file
self.modification_changed(index=index)
File "C:\Users\Andy\AppData\Local\Programs\Spyder\pkgs\spyder\plugins\editor\widgets\editor.py", line 2550, in modification_changed
finfo = self.data[index]
IndexError: list index out of range
Versions
- Spyder version: 4.2.1
- Python version: 3.7.9
- Qt version: 5.12.10
- PyQt5 version: 5.12.3
- Operating System: Windows 10
Dependencies
# Mandatory:
atomicwrites >=1.2.0 : 1.4.0 (OK)
chardet >=2.0.0 : 4.0.0 (OK)
cloudpickle >=0.5.0 : 1.6.0 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree : None (OK)
IPython >=7.6.0 : 7.19.0 (OK)
jedi =0.17.2 : 0.17.2 (OK)
jsonschema >=3.2.0 : 3.2.0 (OK)
keyring >=17.0.0 : 21.5.0 (OK)
nbconvert >=4.0 : 6.0.7 (OK)
numpydoc >=0.6.0 : 1.1.0 (OK)
paramiko >=2.4.0 : 2.7.2 (OK)
parso =0.7.0 : 0.7.0 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=5.3 : 5.7.3 (OK)
pygments >=2.0 : 2.7.3 (OK)
pylint >=1.0 : 2.6.0 (OK)
pyls >=0.36.2;<1.0.0 : 0.36.2 (OK)
pyls_black >=0.4.6 : 0.4.6 (OK)
pyls_spyder >=0.3.0 : 0.3.0 (OK)
qdarkstyle >=2.8 : 2.8.1 (OK)
qtawesome >=0.5.7 : 1.0.2 (OK)
qtconsole >=5.0.1 : 5.0.1 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.4 (OK)
setuptools >=39.0.0 : 51.0.0 (OK)
sphinx >=0.6.6 : 3.3.1 (OK)
spyder_kernels >=1.10.1;<1.11.0 : 1.10.1 (OK)
textdistance >=4.2.0 : 4.2.0 (OK)
three_merge >=0.1.1 : 0.1.1 (OK)
watchdog : 1.0.2 (OK)
zmq >=17 : 20.0.0 (OK)
# Optional:
cython >=0.21 : 0.29.21 (OK)
matplotlib >=2.0.0 : 3.3.3 (OK)
numpy >=1.7 : 1.19.3 (OK)
pandas >=1.1.1 : 1.1.5 (OK)
scipy >=0.17.0 : 1.5.4 (OK)
sympy >=0.7.3 : 1.7.1 (OK)
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Python error when trying to save a new file: IndexError: list ...
This works for me. I think your workbook needs to be setup with a sheet to be valid. import xlwt workbook = xlwt....
Read more >IndexError on load_workbook - Google Groups
Obviously, the original file is saved as xlsx with Libreoffice. ... This is used to determine the formatting defined for this named cell...
Read more >How to turn off AutoFormatting of my XAML on save
I create a WPF app and make changes to the XAML, use ctrl+s to save file, and it will not automatically format. Could...
Read more >traceback — Print or retrieve a stack traceback — Python 3.11 ...
If file is omitted or None , the output goes to sys.stderr ; otherwise it should be an open file ... It is...
Read more >List Index Out of Range – Python Error Message Solved
Why does the Indexerror: list index out of range error occur in Python? Using an index number that is out of the range...
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
Ok, I finally found the cause of this problem: closing tabs in the editor while a formatting operation is in process! That can be seen in the gif below:
@dalthviz, I think the solution is to use the file name, instead of the tab index, in the
modification_changed
andanalyze_script
methods ofEditorStack
. I got this clue from a comment in_save_file
:https://github.com/spyder-ide/spyder/blob/d8b9b022d08a7b4013426470aa5c15a236f703ba/spyder/plugins/editor/widgets/editor.py#L1930-L1933
Ok, that’s really good to know, thanks for testing. Let’s wait to see if someone with 5.3 has this problem before closing.