Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The value of Py_SetPath is not used to populate the configuration #82415

Closed
pablogsal opened this issue Sep 20, 2019 · 33 comments
Closed

The value of Py_SetPath is not used to populate the configuration #82415

pablogsal opened this issue Sep 20, 2019 · 33 comments
Labels
3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pablogsal
Copy link
Member

BPO 38234
Nosy @vstinner, @ambv, @koobs, @zooba, @pablogsal, @miss-islington
PRs
  • bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called #16298
  • bpo-38234: Remove _PyPathConfig.dll_path #16307
  • [3.8] bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298) #16312
  • [3.8] bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298) #16313
  • bpo-38234: Fix _PyConfig_InitPathConfig() #16335
  • [3.8] bpo-38234: Fix _PyConfig_InitPathConfig() (GH-16335) #16336
  • bpo-38234: read_pth_file() now returns PyStatus #16338
  • [3.8] bpo-38234: Fix Windows _PyPathConfig_Calculate() #16339
  • [3.8] bpo-38234: read_pth_file() now returns PyStatus (GH-16338) #16340
  • bpo-38234: Py_SetPath() uses the program full path #16357
  • bpo-38234: Add tests for Python init path config #16358
  • bpo-38234: test_embed: test pyvenv.cfg and pybuilddir.txt #16366
  • bpo-38234: Cleanup getpath.c #16367
  • bpo-38234: Fix test_embed pathconfig tests #16390
  • bpo-38234: Add test_init_setpath_config() to test_embed #16402
  • bpo-38234: Complete init config documentation #16404
  • bpo-38234: Fix test_embed.test_init_setpath_config() on FreeBSD #16406
  • bpo-38234: Py_Initialize() sets global path configuration #16421
  • [3.8] bpo-38234: Backport path configuration changes from master #16423
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-10-22.22:51:02.493>
    created_at = <Date 2019-09-20.15:19:54.329>
    labels = ['interpreter-core', 'type-bug', '3.8', '3.9']
    title = 'The value of Py_SetPath is not used to populate the configuration'
    updated_at = <Date 2019-10-22.22:51:02.492>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2019-10-22.22:51:02.492>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-10-22.22:51:02.493>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-09-20.15:19:54.329>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38234
    keywords = ['patch', '3.8regression']
    message_count = 33.0
    messages = ['352856', '352857', '352859', '352862', '352871', '352909', '352913', '352914', '352915', '353030', '353031', '353032', '353034', '353035', '353037', '353042', '353043', '353096', '353099', '353124', '353128', '353129', '353130', '353205', '353241', '353254', '353256', '353277', '353304', '353306', '353309', '353397', '355167']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'lukasz.langa', 'koobs', 'steve.dower', 'pablogsal', 'miss-islington']
    pr_nums = ['16298', '16307', '16312', '16313', '16335', '16336', '16338', '16339', '16340', '16357', '16358', '16366', '16367', '16390', '16402', '16404', '16406', '16421', '16423']
    priority = None
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38234'
    versions = ['Python 3.8', 'Python 3.9']

    @pablogsal
    Copy link
    Member Author

    When calling Py_SetPath(), the value that is passed in is ignored.

    @pablogsal pablogsal added 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Sep 20, 2019
    @vstinner
    Copy link
    Member

    It's a 3.8 regression: I set the priority to release blocker.

    @pablogsal
    Copy link
    Member Author

    A very simple way to reproduce the bug:

    Using pyInstaller, after applying these patches (to fix other Python3.8 issues)

    pyinstaller/pyinstaller#4441
    pyinstaller/pyinstaller#4440

    you will get

    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'

    This is because Python will use the default value for sys.path, including the "lib" subdirectory:

    /dist/hello/lib/python3.8
    ^----------------> This should not be here

    Instead, that value should be the one that pyinstaller passes when calling Py_SetPath() here:

    https://github.com/pyinstaller/pyinstaller/blob/develop/bootloader/src/pyi_pythonlib.c#L495

    So it should be:

    /dist/hello/python3.8

    @vstinner
    Copy link
    Member

    That's a regression that I introduced between Python 3.7 and 3.8 when refactoring _PyCoreConfig/_PyPathConfig code into PyConfig/_PyPathConfig.

    Previously, if Py_SetPath() was called, the specified string was used to fill config->module_search_paths. Now, this string is basically ignored.

    PR 16298 fix this regression.

    @vstinner
    Copy link
    Member

    Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding

    I created bpo-38236 "Dump the Python path configuration at the first import error" which should ease to debug such issues.

    @vstinner
    Copy link
    Member

    New changeset c422167 by Victor Stinner in branch 'master':
    bpo-38234: Remove _PyPathConfig.dll_path (GH-16307)
    c422167

    @vstinner
    Copy link
    Member

    New changeset e267793 by Victor Stinner in branch 'master':
    bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298)
    e267793

    @vstinner
    Copy link
    Member

    New changeset 9f3dcf8 by Victor Stinner in branch '3.8':
    [3.8] bpo-38234: Fix PyConfig_Read() when Py_SetPath() was called (GH-16298) (GH-16313)
    9f3dcf8

    @vstinner
    Copy link
    Member

    When calling Py_SetPath(), the value that is passed in is ignored.

    I fixed this regression. Thanks for the bug report.

    @zooba
    Copy link
    Member

    zooba commented Sep 23, 2019

    Why are we keeping the DLL path around at all? It should only be being used in 1-2 places during path calculation.

    @vstinner
    Copy link
    Member

    Steve:

    Why are we keeping the DLL path around at all? It should only be being used in 1-2 places during path calculation.

    _PyPathConfig_Init() initializes _Py_dll_path global variable which is only used by _Py_CheckPython3(). _Py_CheckPython3() is called at each _PyImport_FindSharedFuncptrWindows() call which is used by _PyImport_LoadDynamicModuleWithSpec() (to import a .pyd extension). I tried to minimize my changes to fix the issue, I tried to leave _Py_CheckPython3() unchanged. But I made one change in _Py_CheckPython3(): it handles the case _Py_dll_path=NULL... which should never occur, but I wasn't 100% sure that it really can never occur.

    Python 3.6 (before my init work), _Py_CheckPython3() used "static wchar_t dllpath[MAXPATHLEN+1];": it was less important when dllpath is initialized.

    --

    _PyPathConfig_Calculate() of PC/getpathp.c now uses a temporary variable which stores the result of _Py_GetDLLPath().

    @zooba
    Copy link
    Member

    zooba commented Sep 23, 2019

    _PyPathConfig_Init() initializes _Py_dll_path global variable which is only used by _Py_CheckPython3().

    Ah okay, maybe I'll take the time later on (in a separate issue) to get rid of it fully. We may as well load python3.dll at startup anyway, it's not expensive.

    @vstinner
    Copy link
    Member

    When calling Py_SetPath(), the value that is passed in is ignored.

    Hum, in fact the bug was even worse: Py_SetPythonHome() and Py_SetProgramName() calls are also ignored. I'm not sure when I introduced these regressions.

    PR 16335 fix this bug as well.

    @vstinner vstinner reopened this Sep 23, 2019
    @vstinner
    Copy link
    Member

    New changeset 9c42f8c by Victor Stinner in branch 'master':
    bpo-38234: Fix _PyConfig_InitPathConfig() (GH-16335)
    9c42f8c

    @vstinner
    Copy link
    Member

    New changeset 3f5409a by Victor Stinner in branch '3.8':
    bpo-38234: Fix _PyConfig_InitPathConfig() (GH-16335) (GH-16336)
    3f5409a

    @vstinner
    Copy link
    Member

    New changeset 85ce0a7 by Victor Stinner in branch 'master':
    bpo-38234: read_pth_file() now returns PyStatus (GH-16338)
    85ce0a7

    @miss-islington
    Copy link
    Contributor

    New changeset 7f7cd89 by Miss Islington (bot) in branch '3.8':
    bpo-38234: read_pth_file() now returns PyStatus (GH-16338)
    7f7cd89

    @vstinner
    Copy link
    Member

    New changeset 1ce152a by Victor Stinner in branch 'master':
    bpo-38234: Py_SetPath() uses the program full path (GH-16357)
    1ce152a

    @vstinner
    Copy link
    Member

    New changeset bb6bf7d by Victor Stinner in branch 'master':
    bpo-38234: Add tests for Python init path config (GH-16358)
    bb6bf7d

    @vstinner
    Copy link
    Member

    New changeset 52ad33a by Victor Stinner in branch 'master':
    bpo-38234: test_embed: test pyvenv.cfg and pybuilddir.txt (GH-16366)
    52ad33a

    @vstinner
    Copy link
    Member

    New changeset 221fd84 by Victor Stinner in branch 'master':
    bpo-38234: Cleanup getpath.c (GH-16367)
    221fd84

    @vstinner
    Copy link
    Member

    The new tests fail on macOS.

    x86-64 High Sierra 3.x:
    https://buildbot.python.org/all/#/builders/145/builds/2469

    ======================================================================
    FAIL: test_init_pybuilddir (test.test_embed.InitConfigTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 1130, in test_init_pybuilddir
        self.check_all_configs("test_init_compat_config", config,
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 681, in check_all_configs
        self.check_config(configs, expected_config)
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 613, in check_config
        self.assertEqual(config, expected)
    AssertionError: {'_co[655 chars]ne, 'module_search_paths': ['/Users/buildbot/b[1407 chars]': 1} != {'_co[655 chars]ne, 'executable': '/var/folders/sy/9hwmqyx14s1[1383 chars]': 1}
      {'_config_init': 1,
       '_init_main': 1,
       '_install_importlib': 1,
       'argv': [''],
       'base_exec_prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
    -  'base_executable': '/private/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/_testembed',
    ?                      

    +  'base_executable': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/_testembed',
       'base_prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
       'buffered_stdio': 1,
       'bytes_warning': 0,
       'check_hash_pycs_mode': 'default',
       'configure_c_stdio': 0,
       'dev_mode': 0,
       'dump_refs': 0,
       'exec_prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
    -  'executable': '/private/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/_testembed',
    ?                 --------
    
    +  'executable': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/_testembed',
       'faulthandler': 0,
       'hash_seed': 0,
       'home': None,
       'import_time': 0,
       'inspect': 0,
       'install_signal_handlers': 1,
       'interactive': 0,
       'isolated': 0,
       'malloc_stats': 0,
       'module_search_paths': ['/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip',
                               '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib',
                               '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/build/lib.macosx-10.13-x86_64-3.9-pydebug',
                               '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip',
                               '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python3.9',
    -                          '/private/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/libdir'],
    ?                           

    + '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmp2a98rb5k/libdir'],
    'optimization_level': 0,
    'parse_argv': 0,
    'parser_debug': 0,
    'pathconfig_warnings': 1,
    'prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
    'program_name': './_testembed',
    'pycache_prefix': None,
    'pythonpath_env': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip:/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib:/Users/buildbot/buildarea/3.x.billenstein-sierra/build/build/lib.macosx-10.13-x86_64-3.9-pydebug',
    'quiet': 0,
    'run_command': None,
    'run_filename': None,
    'run_module': None,
    'show_alloc_count': 0,
    'show_ref_count': 0,
    'site_import': 1,
    'skip_source_first_line': 0,
    'tracemalloc': 0,
    'use_environment': 1,
    'use_hash_seed': 0,
    'user_site_directory': 1,
    'verbose': 0,
    'warnoptions': [],
    'write_bytecode': 1,
    'xoptions': []}

    ======================================================================
    FAIL: test_init_pyvenv_cfg (test.test_embed.InitConfigTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 1182, in test_init_pyvenv_cfg
        self.check_all_configs("test_init_compat_config", config,
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 681, in check_all_configs
        self.check_config(configs, expected_config)
      File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_embed.py", line 613, in check_config
        self.assertEqual(config, expected)
    AssertionError: {'_co[655 chars]ne, 'module_search_paths': ['/Users/buildbot/b[1416 chars]': 1} != {'_co[655 chars]ne, 'executable': '/var/folders/sy/9hwmqyx14s1[1400 chars]': 1}
      {'_config_init': 1,
       '_init_main': 1,
       '_install_importlib': 1,
       'argv': [''],
       'base_exec_prefix': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmprrz3csek',
    -  'base_executable': '/private/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmpczgnz4r3/_testembed',
    ?                      

    +  'base_executable': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmpczgnz4r3/_testembed',
       'base_prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
       'buffered_stdio': 1,
       'bytes_warning': 0,
       'check_hash_pycs_mode': 'default',
       'configure_c_stdio': 0,
       'dev_mode': 0,
       'dump_refs': 0,
       'exec_prefix': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmprrz3csek',
    -  'executable': '/private/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmpczgnz4r3/_testembed',
    ?                 

    + 'executable': '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmpczgnz4r3/_testembed',
    'faulthandler': 0,
    'hash_seed': 0,
    'home': None,
    'import_time': 0,
    'inspect': 0,
    'install_signal_handlers': 1,
    'interactive': 0,
    'isolated': 0,
    'malloc_stats': 0,
    'module_search_paths': ['/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip',
    '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib',
    '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/build/lib.macosx-10.13-x86_64-3.9-pydebug',
    '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip',
    '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python3.9',
    '/var/folders/sy/9hwmqyx14s11577cvgzwf2v40000gt/T/tmprrz3csek/lib/python3.9/lib-dynload'],
    'optimization_level': 0,
    'parse_argv': 0,
    'parser_debug': 0,
    'pathconfig_warnings': 1,
    'prefix': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target',
    'program_name': './_testembed',
    'pycache_prefix': None,
    'pythonpath_env': '/Users/buildbot/buildarea/3.x.billenstein-sierra/build/target/lib/python39.zip:/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib:/Users/buildbot/buildarea/3.x.billenstein-sierra/build/build/lib.macosx-10.13-x86_64-3.9-pydebug',
    'quiet': 0,
    'run_command': None,
    'run_filename': None,
    'run_module': None,
    'show_alloc_count': 0,
    'show_ref_count': 0,
    'site_import': 1,
    'skip_source_first_line': 0,
    'tracemalloc': 0,
    'use_environment': 1,
    'use_hash_seed': 0,
    'user_site_directory': 1,
    'verbose': 0,
    'warnoptions': [],
    'write_bytecode': 1,
    'xoptions': []}

    @vstinner
    Copy link
    Member

    And on FreeBSD.

    AMD64 FreeBSD CURRENT Shared 3.x:
    https://buildbot.python.org/all/#/builders/168/builds/1510

    ======================================================================
    FAIL: test_init_pybuilddir (test.test_embed.InitConfigTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 1130, in test_init_pybuilddir
        self.check_all_configs("test_init_compat_config", config,
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 681, in check_all_configs
        self.check_config(configs, expected_config)
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 613, in check_config
        self.assertEqual(config, expected)
    AssertionError: {'_co[671 chars]ne, 'module_search_paths': ['/usr/home/buildbo[1297 chars]': 1} != {'_co[671 chars]ne, 'executable': '/tmp/tmpsa4mgwz2/_testembed[1285 chars]': 1}
      {'_config_init': 1,
       '_init_main': 1,
       '_install_importlib': 1,
       'argv': [''],
       'base_exec_prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
    -  'base_executable': '/var/tmp/tmpsa4mgwz2/_testembed',
    ?                      

    +  'base_executable': '/tmp/tmpsa4mgwz2/_testembed',
       'base_prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
       'buffered_stdio': 1,
       'bytes_warning': 0,
       'check_hash_pycs_mode': 'default',
       'configure_c_stdio': 0,
       'dev_mode': 0,
       'dump_refs': 0,
       'exec_prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
    -  'executable': '/var/tmp/tmpsa4mgwz2/_testembed',
    ?                 ----
    
    +  'executable': '/tmp/tmpsa4mgwz2/_testembed',
       'faulthandler': 0,
       'hash_seed': 0,
       'home': None,
       'import_time': 0,
       'inspect': 0,
       'install_signal_handlers': 1,
       'interactive': 0,
       'isolated': 0,
       'malloc_stats': 0,
       'module_search_paths': ['/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip',
                               '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib',
                               '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/build/lib.freebsd-13.0-CURRENT-amd64-3.9-pydebug',
                               '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip',
                               '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python3.9',
    -                          '/var/tmp/tmpsa4mgwz2/libdir'],
    ?                           

    + '/tmp/tmpsa4mgwz2/libdir'],
    'optimization_level': 0,
    'parse_argv': 0,
    'parser_debug': 0,
    'pathconfig_warnings': 1,
    'prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
    'program_name': './_testembed',
    'pycache_prefix': None,
    'pythonpath_env': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip:/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib:/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/build/lib.freebsd-13.0-CURRENT-amd64-3.9-pydebug',
    'quiet': 0,
    'run_command': None,
    'run_filename': None,
    'run_module': None,
    'show_alloc_count': 0,
    'show_ref_count': 0,
    'site_import': 1,
    'skip_source_first_line': 0,
    'tracemalloc': 0,
    'use_environment': 1,
    'use_hash_seed': 0,
    'user_site_directory': 1,
    'verbose': 0,
    'warnoptions': [],
    'write_bytecode': 1,
    'xoptions': []}

    ======================================================================
    FAIL: test_init_pyvenv_cfg (test.test_embed.InitConfigTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 1182, in test_init_pyvenv_cfg
        self.check_all_configs("test_init_compat_config", config,
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 681, in check_all_configs
        self.check_config(configs, expected_config)
      File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_embed.py", line 613, in check_config
        self.assertEqual(config, expected)
    AssertionError: {'_co[671 chars]ne, 'module_search_paths': ['/usr/home/buildbo[1216 chars]': 1} != {'_co[671 chars]ne, 'executable': '/tmp/tmpszvtbyq4/_testembed[1208 chars]': 1}
      {'_config_init': 1,
       '_init_main': 1,
       '_install_importlib': 1,
       'argv': [''],
       'base_exec_prefix': '/tmp/tmpr0gyjdqs',
    -  'base_executable': '/var/tmp/tmpszvtbyq4/_testembed',
    ?                      

    +  'base_executable': '/tmp/tmpszvtbyq4/_testembed',
       'base_prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
       'buffered_stdio': 1,
       'bytes_warning': 0,
       'check_hash_pycs_mode': 'default',
       'configure_c_stdio': 0,
       'dev_mode': 0,
       'dump_refs': 0,
       'exec_prefix': '/tmp/tmpr0gyjdqs',
    -  'executable': '/var/tmp/tmpszvtbyq4/_testembed',
    ?                 

    + 'executable': '/tmp/tmpszvtbyq4/_testembed',
    'faulthandler': 0,
    'hash_seed': 0,
    'home': None,
    'import_time': 0,
    'inspect': 0,
    'install_signal_handlers': 1,
    'interactive': 0,
    'isolated': 0,
    'malloc_stats': 0,
    'module_search_paths': ['/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip',
    '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib',
    '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/build/lib.freebsd-13.0-CURRENT-amd64-3.9-pydebug',
    '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip',
    '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python3.9',
    '/tmp/tmpr0gyjdqs/lib/python3.9/lib-dynload'],
    'optimization_level': 0,
    'parse_argv': 0,
    'parser_debug': 0,
    'pathconfig_warnings': 1,
    'prefix': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target',
    'program_name': './_testembed',
    'pycache_prefix': None,
    'pythonpath_env': '/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/target/lib/python39.zip:/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib:/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/build/lib.freebsd-13.0-CURRENT-amd64-3.9-pydebug',
    'quiet': 0,
    'run_command': None,
    'run_filename': None,
    'run_module': None,
    'show_alloc_count': 0,
    'show_ref_count': 0,
    'site_import': 1,
    'skip_source_first_line': 0,
    'tracemalloc': 0,
    'use_environment': 1,
    'use_hash_seed': 0,
    'user_site_directory': 1,
    'verbose': 0,
    'warnoptions': [],
    'write_bytecode': 1,
    'xoptions': []}

    @vstinner
    Copy link
    Member

    New changeset 00508a7 by Victor Stinner in branch 'master':
    bpo-38234: Fix test_embed pathconfig tests (GH-16390)
    00508a7

    @vstinner
    Copy link
    Member

    New changeset 8bf39b6 by Victor Stinner in branch 'master':
    bpo-38234: Add test_init_setpath_config() to test_embed (GH-16402)
    8bf39b6

    @vstinner
    Copy link
    Member

    New changeset 88feaec by Victor Stinner in branch 'master':
    bpo-38234: Complete init config documentation (GH-16404)
    88feaec

    @vstinner
    Copy link
    Member

    New changeset 49d99f0 by Victor Stinner in branch 'master':
    bpo-38234: Fix test_embed.test_init_setpath_config() on FreeBSD (GH-16406)
    49d99f0

    @vstinner
    Copy link
    Member

    Oh, there is a regression:

    vstinner@apu$ ./python
    Python 3.9.0a0 (heads/master:88feaecd46, Sep 26 2019, 03:26:37) 
    [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import _tkinter
    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

    PyInit__tkinter() calls Py_GetProgramName(). But Python initialization no longer copies PyConfig path configuration into _Py_path_info (the global configuration). So Python has to recompute the path configuration which logs 3 warnings.

    @vstinner
    Copy link
    Member

    New changeset 12f2f17 by Victor Stinner in branch 'master':
    bpo-38234: Py_Initialize() sets global path configuration (GH-16421)
    12f2f17

    @vstinner
    Copy link
    Member

    New changeset 96c8475 by Victor Stinner in branch '3.8':
    [3.8] bpo-38234: Backport init path config changes from master (GH-16423)
    96c8475

    @vstinner
    Copy link
    Member

    Oh, there is a regression: (...) PyInit__tkinter() calls Py_GetProgramName(). But Python initialization no longer copies PyConfig path configuration into _Py_path_info (the global configuration). So Python has to recompute the path configuration which logs 3 warnings.

    It's fixed by commit 12f2f17 which adds new tests to prevent any regression.

    @vstinner
    Copy link
    Member

    Oh, the main issue has been fixed and I added a lot of tests. So I remove the "release blocker" priority.

    I would like to keep the issue open since I plan to do one more change: use PyWideStringList in _PyPathConfig for module_search_paths to support paths which contains DELIM (":" on Unix).

    @vstinner
    Copy link
    Member

    The initial issue has been fixed, I close the issue.

    I would like to keep the issue open since I plan to do one more change: use PyWideStringList in _PyPathConfig for module_search_paths to support paths which contains DELIM (":" on Unix).

    I may use bpo-38353 instead for that. See also bpo-31210.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants