Roger Serwy added the comment:
It's a "race condition" due to ColorDelegator calling .update() in its
recolorize method. The call to .update() flushes pending events, including
callbacks into Python code that can change out the ColorDelegator in the
Percolator chain.
Here's a way to trigger this bug reliably. First we need an unreasonably large
file that will make the syntax highlighting routine take a while. This code
will generate such a file:
fid = open('/tmp/bigfile.py', 'w')
L = '\n'.join(map(lambda x: "#%i\n'%i'\n" % (x,x), range(10000)))
fid.writelines(L)
fid.close()
These next two steps need to be performed quickly to trigger the "race
condition."
$ python -m idlelib.idle -e /tmp/bigfile.py
As soon as it loads, press Ctrl+Shift+S to bring up the Save-As dialog.
You can take your time now. Overwrite the file. This triggers the
filename_change_hook to call ResetColorizer, which removes the current
ColorDelegator from the Percolator chain and inserts a new one. Wait a moment
for the traceback to arrive.
The attached patch fixes the issue. When the ColorDelegator is removed by
Percolator's removefilter, the delegate is set to None. The patch detects that
condition and then sets flags to stop the colorizer from continuing.
In testing for this bug, I encountered another one. Pressing Alt-F4 quickly
after the window loading bigfile appears triggers another traceback. I'll open
a separate issue for that.
----------
keywords: +patch
nosy: +georg.brandl, larry
stage: -> patch review
versions: +Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29650/stop_colorizer.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17613>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com