Skip to content

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

Open
@mhsmith

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions