bpo-32030: Add _PyCoreConfig.module_search_paths#4954
bpo-32030: Add _PyCoreConfig.module_search_paths#4954vstinner merged 4 commits intopython:masterfrom vstinner:module_search_paths
Conversation
|
Oh. Calling _PyPathConfig_Init() before _PyMem_SetupAllocators() doesn't work. _PyPathConfig_Init() -> _Py_wreadlink -> Py_EncodeLocale -> PyMem_Raw -> pymalloc_alloc pymalloc_alloc() calls PyMem_RawRealloc() to allocate the arenas array. But if _PyMem_SetupAllocators() change the RAW allocator, pymalloc_alloc() will crash when resizing arenas... In short, PyMem_Malloc() must be called before _PyMem_SetupAllocators(). _PyPathConfig_Init() must be modified to only use the RAW memory allocator. |
|
In other pull requests (now merged), I modified _PyPathConfig_Calculate() to not use the Python API internally, but only regular C functions. I rebased this PR on top of it. But I'm not sure that @ncoghlan likes this change. I will wait his feedback before merging this PR. |
|
test_site fails on AppVeyor. |
|
While I initially thought this might conflict with some future plans I had
for refactoring how we configure the import system at startup, an off-list
discussion with Victor convinced me that was not the case.
So while I haven't reviewed the details of the PR (still on vacation!), I'm
OK with the idea in principle.
|
_PyCoreConfig_Read() is now responsible to compute sys.path. So sys.path is now computed before calling _Py_InitializeCore(). Changes: * Add nmodule_search_path, module_search_paths, executable, prefix, base_prefix, exec_prefix and base_exec_prefix to _PyCoreConfig * _PyMainInterpreterConfig_Read() now only converts wchar_t** lists into a Python list, it doesn't compute sys.path anymore.
|
I rebased my PR. |
Calling _PyCoreConfig_Read() requires to set global configuration variables, and then get again updated global configuration variables.
|
@ncoghlan: Oh, this patch adds another layer of uglyness in main.c: global configuration flags should be set before calling _PyPathConfig_Init(), and then get again to get updated values... Maybe _PyPathConfig_Init() shouldn't read nor write these global variables... |
_PyCoreConfig_Read() is now responsible to compute sys.path.
So sys.path is now computed before calling _Py_InitializeCore().
Changes:
base_prefix, exec_prefix and base_exec_prefix to _PyCoreConfig
into a Python list, it doesn't compute sys.path anymore.
https://bugs.python.org/issue32030