This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter nested SystemExit
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Abraham Karplus, asvetlov, benjamin.peterson, gpolo, python-dev
Priority: normal Keywords: easy

Created on 2012-11-30 18:14 by Abraham Karplus, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg176698 - (view) Author: Abraham Karplus (Abraham Karplus) Date: 2012-11-30 18:14
When a callback function gets called from Tkinter and raises SystemExit (either directly or through sys.exit), a new SystemExit exception is raised with the original exception as its code field, such as
SystemExit(SystemExit(),)
This is due to a bug in Tkinter's CallWrapper, where it has
except SystemExit as msg:
    raise SystemExit(msg)
which since msg is a SystemExit instance, creates the nesting. This bug did not exist in Python 2 because there the code was
except SystemExit, msg:
    raise SystemExit, msg
and this raises msg, as it already is a SystemExit instance. I suspect the bug was introduced by using the 2to3 tool, as it will do the conversion. If so, this is a bug in 2to3, as the two snippets are not functionally identical.
msg176845 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-03 14:13
New changeset b742bbf6b07f by Andrew Svetlov in branch '3.2':
Issue #16583: Prevent nesting SystemExit in tkinter.CallWrapper
http://hg.python.org/cpython/rev/b742bbf6b07f

New changeset 96b6e6522a1d by Andrew Svetlov in branch '3.3':
Merge issue #16583: Prevent nesting SystemExit in tkinter.CallWrapper
http://hg.python.org/cpython/rev/96b6e6522a1d

New changeset 657caf5d3eb1 by Andrew Svetlov in branch 'default':
Merge issue #16583: Prevent nesting SystemExit in tkinter.CallWrapper
http://hg.python.org/cpython/rev/657caf5d3eb1
msg176846 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-03 14:18
Fixed. Thanks for report.

As tkinter code is not processed via 2to3 tool now, I've fixed tkinter/__init__.py and like to close the issue.

If there are problems in 2to3 please open new ticket dedicated to 2to3 tool only, not related to tkinter.
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60787
2012-12-03 14:18:31asvetlovsetstatus: open -> closed

components: - 2to3 (2.x to 3.x conversion tool)

keywords: + easy
nosy: + asvetlov
messages: + msg176846
resolution: fixed
stage: resolved
2012-12-03 14:13:58python-devsetnosy: + python-dev
messages: + msg176845
2012-11-30 19:58:30serhiy.storchakasetnosy: + benjamin.peterson, gpolo

components: + 2to3 (2.x to 3.x conversion tool)
versions: - Python 3.1
2012-11-30 18:14:43Abraham Karpluscreate