-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Py_Main and Py_RunMain SystemExit documentation does not match actual behavior #133264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you want to propose a PR to update the documentation? |
I considered it, but it's not clear to me whether the documentation or the implementation is wrong. |
You're correct that |
But what about |
|
Yes, that's my point. Neither function currently exits the process on an unhandled |
Correct, the behavior changed. The documentation should be updated. |
Correction: these changes were made on purpose. |
OK, it looks like this was done in #13390 in 2019, so anyone who was affected by the change has already adapted to it. So I'll make a PR to update the documentation. |
…handle SystemExit (pythonGH-135337) (cherry picked from commit b706ff0) Co-authored-by: Malcolm Smith <smith@chaquo.com>
…handle SystemExit (pythonGH-135337) (cherry picked from commit b706ff0) Co-authored-by: Malcolm Smith <smith@chaquo.com>
As far as why #8023 didn't get this right: I forgot the behaviour had changed, and added the outdated info from the Thanks for picking up and resolving the oversight! |
Uh oh!
There was an error while loading. Please reload this page.
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 unhandledSystemExit
.But 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 inpymain_err_print
, which specifically checks forSystemExit
in order to avoid passing it toPyErr_Print
, which is whereexit
would actually be called.My understanding is that
Py_RunMain
was intended for an embedded context, in which case exiting the process is probably not desirable.The 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.@vstinner @ncoghlan
Linked PRs
The text was updated successfully, but these errors were encountered: