gh-152132: Fix bugs and enhance Py_RunMain()#153461
Merged
Merged
Conversation
* Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Add pymain_set_path0() function. * Simplify pymain_run_startup(): avoid strerror() which is decoded from the wrong encoding. Instead display the exception, Py_fopen() raises an OSError with the path object. * Add pymain_error() and pyrun_error(): write the error message to sys.stderr instead of the C stream stderr. * Add _PySys_FormatV() function. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception.
vstinner
added a commit
to vstinner/cpython
that referenced
this pull request
Jul 9, 2026
* Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception.
vstinner
added a commit
to vstinner/cpython
that referenced
this pull request
Jul 9, 2026
* Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception.
|
GH-153466 is a backport of this pull request to the 3.15 branch. |
vstinner
added a commit
that referenced
this pull request
Jul 10, 2026
* Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception.
vstinner
added a commit
that referenced
this pull request
Jul 10, 2026
…153468) [3.15] gh-152132: Fix bugs in Py_RunMain() (GH-153461) (GH-153466) * Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception. (cherry picked from commit cecafeb) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this pull request
Jul 10, 2026
…153467) [3.15] gh-152132: Fix bugs in Py_RunMain() (GH-153461) (GH-153466) * Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception. (cherry picked from commit cecafeb) Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.