summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-18 17:09:59 (GMT)
committerGitHub <noreply@github.com>2023-09-18 17:09:59 (GMT)
commitc829975428253568d47ebfc3104fa7386b5e0b58 (patch)
tree41140825b12fde7699cf05b2bf73724d4b6b917a /Python
parent74f315edd01b4d6c6c99e50c03a90116820d8d47 (diff)
downloadcpython-c829975428253568d47ebfc3104fa7386b5e0b58.zip
cpython-c829975428253568d47ebfc3104fa7386b5e0b58.tar.gz
cpython-c829975428253568d47ebfc3104fa7386b5e0b58.tar.bz2
Fix error handling in _PySys_UpdateConfig() (GH-109524)
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index fed1281..9c1ee02 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -3502,7 +3502,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
if (config->pycache_prefix != NULL) {
SET_SYS_FROM_WSTR("pycache_prefix", config->pycache_prefix);
} else {
- PyDict_SetItemString(sysdict, "pycache_prefix", Py_None);
+ if (PyDict_SetItemString(sysdict, "pycache_prefix", Py_None) < 0) {
+ return -1;
+ }
}
COPY_LIST("argv", config->argv);
@@ -3516,7 +3518,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
SET_SYS_FROM_WSTR("_stdlib_dir", stdlibdir);
}
else {
- PyDict_SetItemString(sysdict, "_stdlib_dir", Py_None);
+ if (PyDict_SetItemString(sysdict, "_stdlib_dir", Py_None) < 0) {
+ return -1;
+ }
}
#undef SET_SYS_FROM_WSTR
@@ -3526,6 +3530,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
// sys.flags
PyObject *flags = _PySys_GetObject(interp, "flags"); // borrowed ref
if (flags == NULL) {
+ if (!_PyErr_Occurred(tstate)) {
+ _PyErr_SetString(tstate, PyExc_RuntimeError, "lost sys.flags");
+ }
return -1;
}
if (set_flags_from_config(interp, flags) < 0) {