Roger Serwy added the comment:

Hello Ger,

Sure, I can explain. IDLE is driven by the Tk event loop. Calls to .update() 
flushes all pending events and expired .after callbacks. 

When close() gets called in PyShell, it places the finalization of the close 
(using close2()) into the Tk event queue as a .after callback. Now, when the 
error message arrives over RPC to the PyShell, it is written to the .text 
widget using the write() method. Here's a snippet from PyShell.py:

            self.text.mark_gravity("iomark", "right")
            count = OutputWindow.write(self, s, tags, "iomark")
            self.text.mark_gravity("iomark", "left")

The OutputWindow.write() command eventually calls .update() before returning. 
That .update() call may flush the close2() callback if the timer expired. If 
so, then .text gets set to None. The next line to restore the gravity to the 
left is doing an attribute lookup for "mark_gravity" on None which causes the 
error.

I hope that clarifies why the patch works.

Can someone verify that the patch works? I've managed to convince myself of its 
validity, but it is always good to get another set of eyes on it in case I 
missed something.

----------
assignee:  -> roger.serwy
stage: test needed -> patch review

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5492>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to