summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/__init__.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-14 18:17:32 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-14 18:17:32 (GMT)
commit9502487781315a5151b5f3e3067baad7ce54e85d (patch)
tree020c6322e5c23ab4c9005572597a79c982b10acd /Lib/tkinter/__init__.py
parentd9cf65f00ec41c251296ae56737a541c68b60510 (diff)
downloadcpython-9502487781315a5151b5f3e3067baad7ce54e85d.zip
cpython-9502487781315a5151b5f3e3067baad7ce54e85d.tar.gz
cpython-9502487781315a5151b5f3e3067baad7ce54e85d.tar.bz2
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.
Diffstat (limited to 'Lib/tkinter/__init__.py')
-rw-r--r--Lib/tkinter/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index c9a2c71..a1ffca1 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