mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-38234: Py_Initialize() sets global path configuration (GH-16421)
* Py_InitializeFromConfig() now writes PyConfig path configuration to the global path configuration (_Py_path_config). * Add test_embed.test_get_pathconfig(). * Fix typo in _PyWideStringList_Join().
This commit is contained in:
parent
3d984a1fd0
commit
12f2f177fc
4 changed files with 64 additions and 11 deletions
|
@ -1230,6 +1230,44 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
api=API_COMPAT, env=env,
|
||||
ignore_stderr=True, cwd=tmpdir)
|
||||
|
||||
def test_global_pathconfig(self):
|
||||
# Test C API functions getting the path configuration:
|
||||
#
|
||||
# - Py_GetExecPrefix()
|
||||
# - Py_GetPath()
|
||||
# - Py_GetPrefix()
|
||||
# - Py_GetProgramFullPath()
|
||||
# - Py_GetProgramName()
|
||||
# - Py_GetPythonHome()
|
||||
#
|
||||
# The global path configuration (_Py_path_config) must be a copy
|
||||
# of the path configuration of PyInterpreter.config (PyConfig).
|
||||
ctypes = support.import_module('ctypes')
|
||||
_testinternalcapi = support.import_module('_testinternalcapi')
|
||||
|
||||
def get_func(name):
|
||||
func = getattr(ctypes.pythonapi, name)
|
||||
func.argtypes = ()
|
||||
func.restype = ctypes.c_wchar_p
|
||||
return func
|
||||
|
||||
Py_GetPath = get_func('Py_GetPath')
|
||||
Py_GetPrefix = get_func('Py_GetPrefix')
|
||||
Py_GetExecPrefix = get_func('Py_GetExecPrefix')
|
||||
Py_GetProgramName = get_func('Py_GetProgramName')
|
||||
Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
|
||||
Py_GetPythonHome = get_func('Py_GetPythonHome')
|
||||
|
||||
config = _testinternalcapi.get_configs()['config']
|
||||
|
||||
self.assertEqual(Py_GetPath().split(os.path.pathsep),
|
||||
config['module_search_paths'])
|
||||
self.assertEqual(Py_GetPrefix(), config['prefix'])
|
||||
self.assertEqual(Py_GetExecPrefix(), config['exec_prefix'])
|
||||
self.assertEqual(Py_GetProgramName(), config['program_name'])
|
||||
self.assertEqual(Py_GetProgramFullPath(), config['executable'])
|
||||
self.assertEqual(Py_GetPythonHome(), config['home'])
|
||||
|
||||
|
||||
class AuditingTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||
def test_open_code_hook(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue