Title: Py_Main and Py_RunMain SystemExit documentation does not match actual behavior · Issue #133264 · python/cpython · GitHub
Open Graph Title: Py_Main and Py_RunMain SystemExit documentation does not match actual behavior · Issue #133264 · python/cpython
X Title: Py_Main and Py_RunMain SystemExit documentation does not match actual behavior · Issue #133264 · python/cpython
Description: A few months ago, #8023 added some details to the docs about how Py_RunMain determines its exit status. Specifically, it wrote thatPy_RunMain exits the process on an unhandled SystemExit. But this isn't the case, at least not when runnin...
Open Graph Description: A few months ago, #8023 added some details to the docs about how Py_RunMain determines its exit status. Specifically, it wrote thatPy_RunMain exits the process on an unhandled SystemExit. But this ...
X Description: A few months ago, #8023 added some details to the docs about how Py_RunMain determines its exit status. Specifically, it wrote thatPy_RunMain exits the process on an unhandled SystemExit. But this ...
Opengraph URL: https://github.com/python/cpython/issues/133264
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Py_Main and Py_RunMain SystemExit documentation does not match actual behavior","articleBody":"A few months ago, #8023 added some details to the docs about how `Py_RunMain` determines its exit status. Specifically, it wrote that`Py_RunMain` exits the process on an unhandled `SystemExit`. \n\nBut this isn't the case, at least not when running via the `pymain_run_module` path (the other paths aren't so clear to me). The relevant code is in `pymain_err_print`, which specifically checks for `SystemExit` in order to avoid passing it to `PyErr_Print`, which is where `exit` would actually be called.\n\nMy understanding is that `Py_RunMain` was intended for an embedded context, in which case exiting the process is probably not desirable. \n\nThe docs of `Py_Main` have specified the process exiting behavior for much longer, but right now it looks like both functions share the same implementation.\n\n@vstinner @ncoghlan \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-135337\n* gh-135394\n* gh-135395\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mhsmith","@type":"Person","name":"mhsmith"},"datePublished":"2025-05-01T16:22:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/133264/cpython/issues/133264"}
| 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:84375cc7-8aed-3ed2-56e4-98901c853207 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D300:1EC7:51AEB50:73F63D6:6A500D28 |
| html-safe-nonce | 24302bd4e909cf5de4666ee82de5973d78be8f2396a433d7f926b66272af98df |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzAwOjFFQzc6NTFBRUI1MDo3M0Y2M0Q2OjZBNTAwRDI4IiwidmlzaXRvcl9pZCI6IjE0NTUyMDQ4Mzk0NDEwNDI3MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 20b070fb607ddcaee58ccf0779aea2d7cd116ec22e28d0ab16c2fe38c7994e60 |
| hovercard-subject-tag | issue:3034203796 |
| 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/133264/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1139f6e099f1c32cb3563959a04e7d8fc47fe555ea78e588194757a6a1da4639/python/cpython/issues/133264 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1139f6e099f1c32cb3563959a04e7d8fc47fe555ea78e588194757a6a1da4639/python/cpython/issues/133264 |
| og:image:alt | A few months ago, #8023 added some details to the docs about how Py_RunMain determines its exit status. Specifically, it wrote thatPy_RunMain exits the process on an unhandled SystemExit. But this ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mhsmith |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56eec25a3430492dd6ec2a480eb33256a0da5192d5714b0db4f5ab5f33203d94 |
| 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 | 93a615b89b7dcbdb6b678f4772931ecc28ada82a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width