This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author roger.serwy
Recipients Boris.FELD, ajaksu2, gerluijten, gpolo, roger.serwy, srid, terry.reedy
Date 2013-04-18.05:48:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366264101.43.0.116714597485.issue5492@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-04-18 05:48:21roger.serwysetrecipients: + roger.serwy, terry.reedy, ajaksu2, gpolo, gerluijten, srid, Boris.FELD
2013-04-18 05:48:21roger.serwysetmessageid: <1366264101.43.0.116714597485.issue5492@psf.upfronthosting.co.za>
2013-04-18 05:48:21roger.serwylinkissue5492 messages
2013-04-18 05:48:20roger.serwycreate