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 calls SystemExit with string
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Abraham Karplus, asvetlov, gpolo, gvanrossum, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

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

Files
File name Uploaded Description Edit
issue16582.diff asvetlov, 2012-12-03 14:04 review
Messages (6)
msg176696 - (view) Author: Abraham Karplus (Abraham Karplus) Date: 2012-11-30 18:03
Exiting a Tkinter application normally results in printing '0' and exiting with error code 1. This is a result of Tkinter's _exit function, whose default argument for code is the string '0'. It then calls SystemExit with the code argument. However, according to the SystemExit documentation "if [the argument] has another type (such as a string), the object’s value is printed and the exit status is one". A simple fix for this would be to change the Tkinter _exit function to convert code to an int before passing it to SystemExit.
msg176842 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-03 14:04
Thanks for report.
The patch is really trivial, but I don't sure if it can be applied to released python versions.
msg176847 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-03 14:25
The code was changed in the changeset e8a2a5e4c7b0.

> def _exit(code='0'):
>-       import sys
>-       sys.exit(getint(code))
>+       raise SystemExit, code

I think it is a bug and should be fixed.
msg176861 - (view) Author: Abraham Karplus (Abraham Karplus) Date: 2012-12-03 18:34
I'd be fine with having it fixed just in 3.4, as it is easy enough to work around for now. (Call deletecommand('exit') and then createcommand('exit', working_exit_function) with working_exit function being the patched version of _exit.)
msg177242 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-09 22:05
New changeset fed68e0bce53 by Andrew Svetlov in branch '3.2':
Issue #16582: use int exit code in tkinter._exit
http://hg.python.org/cpython/rev/fed68e0bce53

New changeset e39677feabe0 by Andrew Svetlov in branch '3.3':
Issue #16582: use int exit code in tkinter._exit
http://hg.python.org/cpython/rev/e39677feabe0

New changeset 5ad5efc847c7 by Andrew Svetlov in branch 'default':
Issue #16582: use int exit code in tkinter._exit
http://hg.python.org/cpython/rev/5ad5efc847c7

New changeset 37c1d20facd7 by Andrew Svetlov in branch '2.7':
Issue #16582: use int exit code in tkinter._exit
http://hg.python.org/cpython/rev/37c1d20facd7
msg177243 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-09 22:05
Fixed. Thanks.
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60786
2012-12-09 22:05:52asvetlovsetstatus: open -> closed
resolution: fixed
messages: + msg177243

stage: resolved
2012-12-09 22:05:21python-devsetnosy: + python-dev
messages: + msg177242
2012-12-03 18:34:22Abraham Karplussetmessages: + msg176861
2012-12-03 14:25:15serhiy.storchakasetnosy: + serhiy.storchaka, gvanrossum
messages: + msg176847
2012-12-03 14:04:34asvetlovsetfiles: + issue16582.diff

nosy: + asvetlov
messages: + msg176842

keywords: + patch
2012-11-30 19:59:42serhiy.storchakasetnosy: + gpolo

versions: - Python 2.6, Python 3.1
2012-11-30 18:03:53Abraham Karpluscreate