Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9502487

Browse files
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.
1 parent d9cf65f commit 9502487

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Lib/tkinter/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,9 +1917,12 @@ def readprofile(self, baseName, className):
19171917
if os.path.isfile(base_py):
19181918
exec(open(base_py).read(), dir)
19191919
def report_callback_exception(self, exc, val, tb):
1920-
"""Internal function. It reports exception on sys.stderr."""
1920+
"""Report callback exception on sys.stderr.
1921+
1922+
Applications may want to override this internal function, and
1923+
should when sys.stderr is None."""
19211924
import traceback
1922-
sys.stderr.write("Exception in Tkinter callback\n")
1925+
print("Exception in Tkinter callback", file=sys.stderr)
19231926
sys.last_type = exc
19241927
sys.last_value = val
19251928
sys.last_traceback = tb

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Core and Builtins
3232
Library
3333
-------
3434

35+
- Issue #22384: An exception in Tkinter callback no longer crashes the program
36+
when it is run with pythonw.exe.
37+
3538
- Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.
3639

3740
- Issue #21147: sqlite3 now raises an exception if the request contains a null

0 commit comments

Comments
 (0)