Terry J. Reedy added the comment:

More thoughts: The reason for explicit __del__ is to release memory resources 
connected to other objects or structures at the behest of the Python instance 
being deleted. If __del__ were only called at shutdown, it would not be needed, 
as all memory is released anyway and we could delete __del__. If __del__ is 
called before shutdown (as would happen if the class were unittested) then 
exceptions would indicate a bug and should not be ignored. From this viewpoint, 
not only should the try: except: be within the loop, but the break should be 
conditioned on the exception message.

  if exc.args[0] == 'can't invoke "bind" command:  application has been 
destroyed': break

The modern solution to this dilemma is to use .close instead of .__del__ and 
either explicitly call .close or have it called in the .__exit__ method of a 
context manager. For Idle classes, this would not be a problem for future test 
code, but it would be much trickier finding all places in current code where 
instances of a class with a .__del__ method get deleted. So a compromise patch 
with conditioned break seems most practical.

I tried a few more experiments: run the .py file (F5, to create a Shell window) 
and then close both windows. Whether the closing was shell first or editor 
first, the messages do not appear. Three runs with -n gave the same results. So 
it seems that the problem only appears when there has never been a shell 
window. I agree with Serhiy (his point 2) that this is disconcerting and could 
indicate a 3.4-specific problem with Tk, tkinter, or Idle.

----------

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

Reply via email to