New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tkinter sliently discards all backgrond Tcl errors #37486
Comments
|
Tkinter silently discards all Tcl errors. Athough this may make Tkinter programs In Tkinter.py is the line self.tk.createcommand('tkerror', _tkerror)where _tkerror is defined as def _tkerror(err):
"""Internal function."""
passThis disables all uses of the tcl procedure bgerror from signalling |
|
Logged In: YES The qualification "silently discards all Tcl errors" is definitely >>> Tkinter.Label(foo="bar")
Traceback (most recent call last):
File "<pyshell#1>", line 1, in ?
Tkinter.Label(foo="bar")
File "E:\Python22\lib\lib-tk\Tkinter.py", line 2261, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "E:\Python22\lib\lib-tk\Tkinter.py", line 1756, in __init__
self.tk.call(
TclError: unknown option "-foo"Instead, it would be more correct to say that all background Can you provide a script that demonstrates this problem? Can you propose a solution for this problem? Please take |
|
Logged In: YES You could create a subclass of Tk that creates a different Anyway, CallWrapper (used when a function is passed to Neither of these things require changing Tkinter.py. I don't seem to be permitted to attach a file, so I'm forced import Tkinter as _Tkinter
class Tk(_Tkinter.Tk):
def __init__(self, *args, **kw):
_Tkinter.Tk.__init__(self, *args, **kw)
self.tk.createcommand('tkerror', self.tkerror)
def report_callback_exception(self, exc, val, tb):
print "callback exception", exc
def tkerror(self, *args):
print "tkerror", args
if __name__ == '__main__':
w = Tk()
w.after_idle(lambda: 1/0)
_Tkinter.Button(w, command="expr 1/0").pack()
w.mainloop() |
|
Logged In: YES But why is Tkinter silencing all Tk (Tcl or Python) errors in the first place? I know I can subclass Tk, but _tkerror is clearly billed as an internal function, |
|
Logged In: YES It is not the case that Tkinter silently discards all Python |
|
Logged In: YES That's right: Tkinter silently discards all background Tcl All errors from Tcl are silenced by def _tkerror(err): pass The proposed solution for this problem is simply to Although Tkinter behaved that way since the beginning, the |
|
Logged In: YES idiscovery, I still would like to see an example that |
|
Logged In: YES What possible reason can you give to ever drop errors silently? One example is in the Python distribution that I asked you about |
|
Logged In: YES It's a basic engineering principle: Don't apply changes that However, my believes should be irrelevant if you can |
|
Logged In: YES Here's an example of the type of error which is discarded by from Tkinter import Button
b = Button(command="expr 1/0")
b.pack()
b.mainloop()When "b" is pressed, "expr" will produce an "Error: divide Of course, I've pointed out in an earlier comment how |
|
Logged In: YES Thanks for the example. Is this the case that this can only |
|
Logged In: YES As far as I can tell, the only way _tkerror can discard an So, for instance, in |
|
Logged In: YES As far as I can tell, the only way _tkerror can discard an So, for instance, in |
|
Logged In: YES It's a basic computer engineering principle not to ignore errors To not believe this problem could ever happen is to assume that For an example of where a bug has been obscured by this, Martin I don't know how you could still assume |
|
Logged In: YES The comment in BUGS.txt is too mysterious to make any sense Uncommenting the line, I get tons of "bad window path name" I don't feel privileged to approve a change here; you should |
|
Uhm, long time without discussion but I'm hoping someone interested may You have to provide a "bgerror" command to Tcl, so it will get invoked If you want to play with it: import Tkinter
def bgerr_handler(msg):
print msg, "<<"
root = Tkinter.Tk()
root.tk.createcommand("bgerror", bgerr_handler)
btn = Tkinter.Button(command="expr 1/0")
btn.pack()
root.mainloop()To get some form of traceback you would need to play with inspect and |
|
@guilherme I take it that you're still interested in this? |
|
This is now 20 years old and there was no agreement on the problem. If there is a problem to fix, it will be raised again. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: