summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-09-26 13:51:50 (GMT)
committerGitHub <noreply@github.com>2019-09-26 13:51:50 (GMT)
commit12f2f177fc483723406d7917194e7f655a20631b (patch)
treef3e1b4227b37efa25e0ca0a487e0d229deba8b95 /Lib
parent3d984a1fd0c05903268542a216fc496074b2e6da (diff)
downloadcpython-12f2f177fc483723406d7917194e7f655a20631b.zip
cpython-12f2f177fc483723406d7917194e7f655a20631b.tar.gz
cpython-12f2f177fc483723406d7917194e7f655a20631b.tar.bz2
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().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_embed.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 92b5136..ab086e2 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -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):