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.

classification
Title: tkFont: simple fix to error at shutdown
Type: Stage:
Components: Tkinter Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: georg.brandl, loewis, reowen
Priority: normal Keywords: patch

Created on 2006-04-11 19:48 by reowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkFont_patch.txt reowen, 2006-04-11 19:48
Messages (2)
msg49983 - (view) Author: Russell Owen (reowen) Date: 2006-04-11 19:48
At shutdown, tkFont may produce the following error
message:
Exception exceptions.AttributeError: "'NoneType' object
has no attribute 'TclError'" in <bound method
Font.__del__ of <tkFont.Font instance at 0x76f418>> ignored

Here's the relevant code as presently implemented:
    def __del__(self):
        try:
            if self.delete_font:
                self._call("font", "delete", self.name)
        except (AttributeError, Tkinter.TclError):
            pass

apparently Tkinter doesn't always exist at shutdown, so
Tkinter.TclError becomes None.TclError, which causes
the trouble.

Here's the trivial fix:

    def __del__(self):
        try:
            if self.delete_font:
                self._call("font", "delete", self.name)
        except Exception:
            pass

Note that this relies on the new exception hierachy in
python 2.5. If this is to be used in 2.4.x then one
should include the usual guard lines before "except
Exception:"
        except (SystemExit, KeyboardInterrupt):
           raise
msg49984 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-04-12 15:29
Logged In: YES 
user_id=849994

Thanks, resolved in rev. 45310, 45311.
History
Date User Action Args
2022-04-11 14:56:16adminsetgithub: 43191
2006-04-11 19:48:09reowencreate