Py_Main and Py_RunMain SystemExit documentation does not match actual behavior · Issue #133264 · python/cpython · GitHub
Skip to content

Py_Main and Py_RunMain SystemExit documentation does not match actual behavior #133264

Description

@mhsmith

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 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.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions