Title: `sys.exit` unpacks its argument if it is a 0- or 1-element tuple · Issue #133548 · python/cpython · GitHub
Open Graph Title: `sys.exit` unpacks its argument if it is a 0- or 1-element tuple · Issue #133548 · python/cpython
X Title: `sys.exit` unpacks its argument if it is a 0- or 1-element tuple · Issue #133548 · python/cpython
Description: Bug report Bug description: The documentation of sys.exit says “The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. [...] If another type of object is passed, None is equiva...
Open Graph Description: Bug report Bug description: The documentation of sys.exit says “The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. [...] If another ...
X Description: Bug report Bug description: The documentation of sys.exit says “The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. [...] If another ...
Opengraph URL: https://github.com/python/cpython/issues/133548
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`sys.exit` unpacks its argument if it is a 0- or 1-element tuple","articleBody":"# Bug report\n\n### Bug description:\n\nThe documentation of [`sys.exit`](https://docs.python.org/3/library/sys.html#sys.exit) says “The optional argument _arg_ can be an integer giving the exit status (defaulting to zero), or another type of object. \\[...] If another type of object is passed, `None` is equivalent to passing zero, and any other object is printed to [`stderr`](https://docs.python.org/3/library/sys.html#sys.stderr) and results in an exit code of 1.” This is no longer true for 0- and 1-element tuples in Python 3.12 and later. It acts like the argument is unpacked: `sys.exit(())` is treated like `sys.exit()` and `sys.exit((x,))` is treated like `sys.exit(x)`.\n\n```console\n$ python3.11 -c 'import sys; sys.exit(())'; echo $?\n()\n1\n\n$ python3.12 -c 'import sys; sys.exit(())'; echo $?\n0\n\n$ python3.11 -c 'import sys; sys.exit((2,))'; echo $?\n(2,)\n1\n\n$ python3.12 -c 'import sys; sys.exit((2,))'; echo $?\n2\n```\n\n### CPython versions tested on:\n\n3.12, 3.13, CPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-135789\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/dscorbett","@type":"Person","name":"dscorbett"},"datePublished":"2025-05-07T02:50:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/133548/cpython/issues/133548"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3d694fea-c6e5-2b1f-d91e-81866cc2249f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFE4:24CD64:17B46F4:1F8150B:696AEA61 |
| html-safe-nonce | 7f1748064ec0b0c37ef717c48aaa985d464e016386ee9d246cb0931e68977162 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkU0OjI0Q0Q2NDoxN0I0NkY0OjFGODE1MEI6Njk2QUVBNjEiLCJ2aXNpdG9yX2lkIjoiMzM2Mzc3MjI1MTQ1NzEyMDg2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e189e872402de4b576e661615ebe37bb8cb6b33158d3491fa4acb3eeef4cb257 |
| hovercard-subject-tag | issue:3044515330 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/133548/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c87e03851abc602e5fd66aa28660ec7b88ccbcf1e190b72d6f8103a283985845/python/cpython/issues/133548 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c87e03851abc602e5fd66aa28660ec7b88ccbcf1e190b72d6f8103a283985845/python/cpython/issues/133548 |
| og:image:alt | Bug report Bug description: The documentation of sys.exit says “The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. [...] If another ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dscorbett |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width