From: Serhiy Storchaka Date: Sun, 14 Sep 2014 18:17:32 +0000 (+0300) Subject: Issue #22384: An exception in Tkinter callback no longer crashes the program X-Git-Tag: v3.4.2rc1~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9502487781315a5151b5f3e3067baad7ce54e85d;p=python Issue #22384: An exception in Tkinter callback no longer crashes the program when it is run with pythonw.exe. Documented that Tk.report_callback_exception() is purposed to be overriden in applications. --- diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index c9a2c71e6e..a1ffca1434 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1917,9 +1917,12 @@ class Tk(Misc, Wm): if os.path.isfile(base_py): exec(open(base_py).read(), dir) def report_callback_exception(self, exc, val, tb): - """Internal function. It reports exception on sys.stderr.""" + """Report callback exception on sys.stderr. + + Applications may want to override this internal function, and + should when sys.stderr is None.""" import traceback - sys.stderr.write("Exception in Tkinter callback\n") + print("Exception in Tkinter callback", file=sys.stderr) sys.last_type = exc sys.last_value = val sys.last_traceback = tb diff --git a/Misc/NEWS b/Misc/NEWS index 523965b447..f7e9fa7cd0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -32,6 +32,9 @@ Core and Builtins Library ------- +- Issue #22384: An exception in Tkinter callback no longer crashes the program + when it is run with pythonw.exe. + - Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X. - Issue #21147: sqlite3 now raises an exception if the request contains a null