New submission from STINNER Victor <[email protected]>:
Extract of _PySys_EndInit():
SET_SYS_FROM_STRING_BORROW("path", config->module_search_path);
sys.path is initialized from _PyMainInterpreterConfig.module_search_path
object: the list of strings is not copied. As a consequence, when sys.path is
modified, _PyMainInterpreterConfig is modified as well. For example, "import
site" modifies sys.path.
I dislike this behavior. I prefer to see _PyMainInterpreterConfig as
"constant": a snapshot of the configuration used to startup Python.
A side effect is that Py_NewInterpreter() copies the modified configuration,
whereas starting from the "original" configuration. For the specific case of
Py_NewInterpreter(), I'm not sure of what is the expected behavior...
Py_NewInterpreter() imports the "site" module again, so it should reapply the
same sys.path change.
Note: I found this bug while working on better tests for global, core and main
configurations: https://github.com/python/cpython/pull/10524
----------
components: Interpreter Core
messages: 329872
nosy: eric.snow, ncoghlan, vstinner
priority: normal
severity: normal
status: open
title: _PySys_EndInit() doesn't copy main interpreter configuration
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35239>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com