How to capture exceptions after the end of the program
Hi all, I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok) Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4680>> ignored and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions? I was getting the same problem with the PhotoImage() but now I am trying to delete all of them before the end of the program to avoid the exceptions. However with fonts I can miss something e.g replace a font and exit afterwards. Thanks in advance Vasilis -- ------------------------------------------------------- Vasilis Vlachoudis Dep. EN-STI-EET Web: home.cern.ch/bnv Tel: +41-22-7679851 Fax: +41-22-7669644 -------------------------------------------------------
On Fri, Jun 25, 2010 at 5:20 AM, Vasilis Vlachoudis < Vasilis.Vlachoudis@cern.ch> wrote:
Hi all,
I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4680>> ignored
and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions?
If you're on linux you can redirect the errors via $ python myfile.py > mylog.txt I'm not sure how you would catch the exceptions, though. -Wayne
Thanks Wayne, unfortunately I cannot do that since I am using the output for other messages Vasilis On 06/25/10 13:14, Wayne Werner wrote:
On Fri, Jun 25, 2010 at 5:20 AM, Vasilis Vlachoudis <Vasilis.Vlachoudis@cern.ch <mailto:Vasilis.Vlachoudis@cern.ch>> wrote:
Hi all,
I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4680>> ignored
and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions?
If you're on linux you can redirect the errors via
$ python myfile.py > mylog.txt
I'm not sure how you would catch the exceptions, though.
-Wayne
-- ------------------------------------------------------- Vasilis Vlachoudis Dep. EN-STI-EET Web: home.cern.ch/bnv Tel: +41-22-7679851 Fax: +41-22-7669644 -------------------------------------------------------
unfortunately I cannot do that since I am using the output for other messages
Vasilis
On 06/25/10 13:14, Wayne Werner wrote:
On Fri, Jun 25, 2010 at 5:20 AM, Vasilis Vlachoudis <Vasilis.Vlachoudis@cern.ch <mailto:Vasilis.Vlachoudis@cern.ch>> wrote:
Hi all,
I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4680>> ignored
and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions?
If you're on linux you can redirect the errors via
$ python myfile.py > mylog.txt
I'm not sure how you would catch the exceptions, though. . . . While I've become quite confused about what "that" is, Vasilis,
On Fri, Jun 25, 2010 at 01:54:57PM +0200, Vasilis Vlachoudis wrote: . . . please be aware that the same data can go to more than one sink. <URL: http://unixhelp.ed.ac.uk/CGI/man-cgi?tee >, for example, might interest you--if you're not already aware of it.
Hi Vasilis, On Fri, 25 Jun 2010 12:20:30 +0200 Vasilis Vlachoudis <Vasilis.Vlachoudis@cern.ch> wrote:
Hi all,
I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in <bound method Font.__del__ of <tkFont.Font instance at 0x2ac0dd4c4680>> ignored
and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions?
I was getting the same problem with the PhotoImage() but now I am trying to delete all of them before the end of the program to avoid the exceptions. However with fonts I can miss something e.g replace a font and exit afterwards.
Can you provide a minimal code example that exhibits the problem? Michael
Unfortunately I was not able to narrow down to a simple code. All my attempts failed and they worked ok. While in the big project is not behaving correctly. The problem I see depends on the gc. If the gc deletes first the Tk_ root window then when it tries to delete the Font.__del__, tcl fails. Which for me is a bit puzzling since there is a backlink of the root in the Font class. However I saw that from python 2.6 the tkFont.Font.__del__ method has changed with respect to the 2.4 and there is a branch to catch the generic exception. When I added this to the tkFont of the 2.4 it worked and absorbed all Exceptions. Vasilis On 06/25/10 22:39, Michael Lange wrote:
Hi Vasilis,
On Fri, 25 Jun 2010 12:20:30 +0200 Vasilis Vlachoudis<Vasilis.Vlachoudis@cern.ch> wrote:
Hi all,
I have a tkinter application that uses several fonts. However only with python 2.4 when the application is closed then I get the following exceptions (with 2.6 it works Ok)
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in<bound method Font.__del__ of<tkFont.Font instance at 0x2ac0dd4c4908>> ignored Exception exceptions.AttributeError: "'NoneType' object has no attribute 'TclError'" in<bound method Font.__del__ of<tkFont.Font instance at 0x2ac0dd4c4680>> ignored
and I have no way of capturing them since they arrive even after the last line of the program. I believe that for some reason the tkinter is deleted before and afterwards it tries to delete the fonts and creates the TclError. Is there a way to protect for these exceptions?
I was getting the same problem with the PhotoImage() but now I am trying to delete all of them before the end of the program to avoid the exceptions. However with fonts I can miss something e.g replace a font and exit afterwards.
Can you provide a minimal code example that exhibits the problem?
Michael
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss
-- ------------------------------------------------------- Vasilis Vlachoudis Dep. EN-STI-EET Web: home.cern.ch/bnv Tel: +41-22-7679851 Fax: +41-22-7669644 -------------------------------------------------------
participants (4)
-
Cameron Laird -
Michael Lange -
Vasilis Vlachoudis -
Wayne Werner