mirror of
https://github.com/python/cpython.git
synced 2026-04-22 03:41:08 +00:00
Revert "bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)" (GH-10660)
This reverts commit d2be9a5c13.
This commit is contained in:
parent
18f3327d9a
commit
a519411573
3 changed files with 13 additions and 28 deletions
|
|
@ -967,8 +967,8 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
|
|||
}
|
||||
|
||||
/* Initialize warnings. */
|
||||
PyObject *warnoptions = PySys_GetObject("warnoptions");
|
||||
if (warnoptions != NULL && PyList_Size(warnoptions) > 0)
|
||||
if (interp->config.warnoptions != NULL &&
|
||||
PyList_Size(interp->config.warnoptions) > 0)
|
||||
{
|
||||
PyObject *warnings_module = PyImport_ImportModule("warnings");
|
||||
if (warnings_module == NULL) {
|
||||
|
|
|
|||
|
|
@ -2464,20 +2464,7 @@ _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config)
|
|||
assert(config->exec_prefix != NULL);
|
||||
assert(config->base_exec_prefix != NULL);
|
||||
|
||||
#define COPY_LIST(KEY, ATTR) \
|
||||
do { \
|
||||
assert(PyList_Check(config->ATTR)); \
|
||||
PyObject *list = PyList_GetSlice(config->ATTR, \
|
||||
0, PyList_GET_SIZE(config->ATTR)); \
|
||||
if (list == NULL) { \
|
||||
return -1; \
|
||||
} \
|
||||
SET_SYS_FROM_STRING_BORROW(KEY, list); \
|
||||
Py_DECREF(list); \
|
||||
} while (0)
|
||||
|
||||
COPY_LIST("path", module_search_path);
|
||||
|
||||
SET_SYS_FROM_STRING_BORROW("path", config->module_search_path);
|
||||
SET_SYS_FROM_STRING_BORROW("executable", config->executable);
|
||||
SET_SYS_FROM_STRING_BORROW("prefix", config->prefix);
|
||||
SET_SYS_FROM_STRING_BORROW("base_prefix", config->base_prefix);
|
||||
|
|
@ -2488,19 +2475,12 @@ _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config)
|
|||
SET_SYS_FROM_STRING_BORROW("argv", config->argv);
|
||||
}
|
||||
if (config->warnoptions != NULL) {
|
||||
COPY_LIST("warnoptions", warnoptions);
|
||||
SET_SYS_FROM_STRING_BORROW("warnoptions", config->warnoptions);
|
||||
}
|
||||
if (config->xoptions != NULL) {
|
||||
PyObject *dict = PyDict_Copy(config->xoptions);
|
||||
if (dict == NULL) {
|
||||
return -1;
|
||||
}
|
||||
SET_SYS_FROM_STRING_BORROW("_xoptions", dict);
|
||||
Py_DECREF(dict);
|
||||
SET_SYS_FROM_STRING_BORROW("_xoptions", config->xoptions);
|
||||
}
|
||||
|
||||
#undef COPY_LIST
|
||||
|
||||
/* Set flags to their final values */
|
||||
SET_SYS_FROM_STRING_INT_RESULT("flags", make_flags());
|
||||
/* prevent user from creating new instances */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue