mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
Close #20500: Don't trigger PyObject_Str assertion at shutdown
This commit is contained in:
parent
c9d1a6b85e
commit
d979e4335d
4 changed files with 28 additions and 2 deletions
|
@ -1792,6 +1792,11 @@ handle_system_exit(void)
|
|||
exitcode = (int)PyLong_AsLong(value);
|
||||
else {
|
||||
PyObject *sys_stderr = _PySys_GetObjectId(&PyId_stderr);
|
||||
/* We clear the exception here to avoid triggering the assertion
|
||||
* in PyObject_Str that ensures it won't silently lose exception
|
||||
* details.
|
||||
*/
|
||||
PyErr_Clear();
|
||||
if (sys_stderr != NULL && sys_stderr != Py_None) {
|
||||
PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue