8000 Fix error handling in _PySys_UpdateConfig() (GH-109524) · python/cpython@c829975 · GitHub
[go: up one dir, main page]

Skip to content

Commit c829975

Browse files
Fix error handling in _PySys_UpdateConfig() (GH-109524)
1 parent 74f315e commit c829975

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Python/sysmodule.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,7 +3502,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
35023502
if (config->pycache_prefix != NULL) {
35033503
SET_SYS_FROM_WSTR("pycache_prefix", config->pycache_prefix);
35043504
} else {
3505-
PyDict_SetItemString(sysdict, "pycache_prefix", Py_None);
3505+
if (PyDict_SetItemString(sysdict, "pycache_prefix", Py_None) < 0) {
3506+
return -1;
3507+
}
35063508
}
35073509

35083510
COPY_LIST("argv", config->argv);
@@ -3516,7 +3518,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
35163518
SET_SYS_FROM_WSTR("_stdlib_dir", stdlibdir);
35173519
}
35183520
else {
3519-
PyDict_SetItemString(sysdict, "_stdlib_dir", Py_None);
3521+
if (PyDict_SetItemString(sysdict, "_stdlib_dir", Py_None) < 0) {
3522+
return -1;
3523+
}
35203524
}
35213525

35223526
#undef SET_SYS_FROM_WSTR
@@ -3526,6 +3530,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
35263530
// sys.flags
35273531
PyObject *flags = _PySys_GetObject(interp, "flags"); // borrowed ref
35283532
if (flags == NULL) {
3533+
if (!_PyErr_Occurred(tstate)) {
3534+
_PyErr_SetString(tstate, PyExc_RuntimeError, "lost sys.flags");
3535+
}
35293536
return -1;
35303537
}
35313538
if (set_flags_from_config(interp, flags) < 0) {

0 commit comments

Comments
 (0)
0