-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Correctly handle errors in PyErr_Set*()
functions
#107915
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
Labels
3.11
only security fixes
3.12
only security fixes
3.13
bugs and security fixes
topic-C-API
type-bug
An unexpected behavior, bug, or error
Comments
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 13, 2023
…Err_Format() Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 13, 2023
…Err_Format() Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 13, 2023
…Err_Format() Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 13, 2023
…Err_Format() Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 13, 2023
…Err_Format() Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
serhiy-storchaka
added a commit
that referenced
this issue
Aug 19, 2023
…rmat() (GH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Aug 19, 2023
…Err_Format() (pythonGH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error. (cherry picked from commit 633ea21) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 19, 2023
… and PyErr_Format() (pythonGH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.. (cherry picked from commit 633ea21) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka
added a commit
that referenced
this issue
Aug 19, 2023
…yErr_Format() (GH-107918) (GH-108135) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error. (cherry picked from commit 633ea21)
Yhg1s
pushed a commit
that referenced
this issue
Aug 20, 2023
…yErr_Format() (GH-107918) (#108134) * gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error. (cherry picked from commit 633ea21) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> * Define PY_SSIZE_T_CLEAN. --------- Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.11
only security fixes
3.12
only security fixes
3.13
bugs and security fixes
topic-C-API
type-bug
An unexpected behavior, bug, or error
C API functions
PyErr_SetFromErrnoWithFilename()
,PyErr_SetExcFromWindowsErrWithFilename()
,PyErr_SetFromWindowsErrWithFilename()
,_PyErr_SetString()
and_PyErr_FormatV()
convert some of their arguments from C string to Python string, but do not check for error. If it fails the behavior is undefined -- it can be ignoring the new error and using None or other default value instead of the string, it can be crash.Linked PRs
The text was updated successfully, but these errors were encountered: