[issue12919] Control what module is imported first
STINNER Victor
report at bugs.python.org
Tue Oct 22 19:08:35 EDT 2019
STINNER Victor <vstinner at python.org> added the comment:
I close the issue since I see disagreement on the feature request.
Modules/getpath.c and PC/getpathp.c use Lib/os.py to detect the stdlib directory.
_PyUnicode_InitEncodings() is the first function importing modules: to import the Python codec of the filesystem encoding. If this import fails, Python now dumps the "path configuration" to help users to debug their setup. See bpo-38236.
Example:
$ PYTHONHOME=/xxx ./python -c pass
Python path configuration:
PYTHONHOME = '/xxx'
PYTHONPATH = (not set)
program name = './python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/home/vstinner/python/master/python'
sys.base_prefix = '/xxx'
sys.base_exec_prefix = '/xxx'
sys.executable = '/home/vstinner/python/master/python'
sys.prefix = '/xxx'
sys.exec_prefix = '/xxx'
sys.path = [
'/xxx/lib/python39.zip',
'/xxx/lib/python3.9',
'/xxx/lib/python3.9/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f845ca19740 (most recent call first):
<no Python frame>
----------
nosy: +vstinner
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue12919>
_______________________________________
More information about the Python-bugs-list
mailing list