summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-02 14:58:58 (GMT)
committerGitHub <noreply@github.com>2023-10-02 14:58:58 (GMT)
commitdf2cdcf22f63ca8b958e99406aff41e7c98f16ad (patch)
tree74b81f851d7fe7bf21217e7f21069375b098fe61 /Python
parente5c860f9d03669f152292fb82665edfc2c01e5ec (diff)
downloadcpython-df2cdcf22f63ca8b958e99406aff41e7c98f16ad.zip
cpython-df2cdcf22f63ca8b958e99406aff41e7c98f16ad.tar.gz
cpython-df2cdcf22f63ca8b958e99406aff41e7c98f16ad.tar.bz2
[3.12] Fix error handling in _PySys_UpdateConfig() (GH-109524) (#109550)
Fix error handling in _PySys_UpdateConfig() (GH-109524) (cherry picked from commit c829975428253568d47ebfc3104fa7386b5e0b58) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 4bd38b4..14f4447 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -3466,7 +3466,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);
@@ -3480,7 +3482,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
@@ -3490,6 +3494,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) {