aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/initconfig.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2025-06-13 00:05:26 +0300
committershadchin <shadchin@yandex-team.com>2025-06-13 00:35:30 +0300
commit796b9088366b10b4cd42885101fc20c0b5709b07 (patch)
treef287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Python/initconfig.c
parentc72bca862651e507d2ff4980ef7f4ff7267a7227 (diff)
downloadydb-796b9088366b10b4cd42885101fc20c0b5709b07.tar.gz
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Python/initconfig.c')
-rw-r--r--contrib/tools/python3/Python/initconfig.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/tools/python3/Python/initconfig.c b/contrib/tools/python3/Python/initconfig.c
index 4cf56864feb..2c76cf86f0b 100644
--- a/contrib/tools/python3/Python/initconfig.c
+++ b/contrib/tools/python3/Python/initconfig.c
@@ -9,6 +9,7 @@
#include "pycore_pylifecycle.h" // _Py_PreInitializeFromConfig()
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()
#include "osdefs.h" // DELIM
@@ -43,7 +44,7 @@ Options (and corresponding environment variables):\n\
-h : print this help message and exit (also -? or --help)\n\
-i : inspect interactively after running script; forces a prompt even\n\
if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
--I : isolate Python from the user's environment (implies -E and -s)\n\
+-I : isolate Python from the user's environment (implies -E, -P and -s)\n\
-m mod : run library module as a script (terminates option list)\n\
-O : remove assert and __debug__-dependent statements; add .opt-1 before\n\
.pyc extension; also PYTHONOPTIMIZE=x\n\
@@ -3144,10 +3145,13 @@ _Py_DumpPathConfig(PyThreadState *tstate)
#define DUMP_SYS(NAME) \
do { \
- obj = PySys_GetObject(#NAME); \
PySys_FormatStderr(" sys.%s = ", #NAME); \
+ if (_PySys_GetOptionalAttrString(#NAME, &obj) < 0) { \
+ PyErr_Clear(); \
+ } \
if (obj != NULL) { \
PySys_FormatStderr("%A", obj); \
+ Py_DECREF(obj); \
} \
else { \
PySys_WriteStderr("(not set)"); \
@@ -3165,7 +3169,8 @@ _Py_DumpPathConfig(PyThreadState *tstate)
DUMP_SYS(exec_prefix);
#undef DUMP_SYS
- PyObject *sys_path = PySys_GetObject("path"); /* borrowed reference */
+ PyObject *sys_path;
+ (void) _PySys_GetOptionalAttrString("path", &sys_path);
if (sys_path != NULL && PyList_Check(sys_path)) {
PySys_WriteStderr(" sys.path = [\n");
Py_ssize_t len = PyList_GET_SIZE(sys_path);
@@ -3175,6 +3180,7 @@ _Py_DumpPathConfig(PyThreadState *tstate)
}
PySys_WriteStderr(" ]\n");
}
+ Py_XDECREF(sys_path);
_PyErr_SetRaisedException(tstate, exc);
}