mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-36763: Fix _PyPreConfig_InitCompatConfig() utf8_mode (GH-13518)
* _PyPreConfig_InitCompatConfig() sets utf8_mode to 0. * Change Py_UTF8Mode default value to 0. * Fix _PyPreConfig_Copy(): copy also _config_init attrbibute. * _PyPreConfig_AsDict() exports _config_init * Fix _PyPreConfig_GetGlobalConfig(): use Py_UTF8Mode if it's greater than 0, even if utf8_mode >= 0. * Add unit tests on environment variables using Python API.
This commit is contained in:
parent
bc2aa81662
commit
20e1e2582e
4 changed files with 77 additions and 11 deletions
|
@ -287,6 +287,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
IGNORE_CONFIG = object()
|
||||
|
||||
PRE_CONFIG_COMPAT = {
|
||||
'_config_init': API_COMPAT,
|
||||
'allocator': PYMEM_ALLOCATOR_NOT_SET,
|
||||
'parse_argv': 0,
|
||||
'configure_locale': 1,
|
||||
|
@ -299,11 +300,13 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'legacy_windows_fs_encoding': 0,
|
||||
})
|
||||
PRE_CONFIG_PYTHON = dict(PRE_CONFIG_COMPAT,
|
||||
_config_init=API_PYTHON,
|
||||
parse_argv=1,
|
||||
coerce_c_locale=GET_DEFAULT_CONFIG,
|
||||
utf8_mode=GET_DEFAULT_CONFIG,
|
||||
)
|
||||
PRE_CONFIG_ISOLATED = dict(PRE_CONFIG_COMPAT,
|
||||
_config_init=API_ISOLATED,
|
||||
configure_locale=0,
|
||||
isolated=1,
|
||||
use_environment=0,
|
||||
|
@ -388,10 +391,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
})
|
||||
|
||||
CORE_CONFIG_PYTHON = dict(CORE_CONFIG_COMPAT,
|
||||
_config_init=API_PYTHON,
|
||||
configure_c_stdio=1,
|
||||
parse_argv=1,
|
||||
)
|
||||
CORE_CONFIG_ISOLATED = dict(CORE_CONFIG_COMPAT,
|
||||
_config_init=API_ISOLATED,
|
||||
isolated=1,
|
||||
use_environment=0,
|
||||
user_site_directory=0,
|
||||
|
@ -611,7 +616,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
else:
|
||||
default_config = self.CORE_CONFIG_COMPAT
|
||||
expected_config = dict(default_config, **expected_config)
|
||||
expected_config['_config_init'] = api
|
||||
|
||||
self.get_expected_config(expected_preconfig,
|
||||
expected_config, env,
|
||||
|
@ -708,7 +712,33 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
self.check_config("test_init_from_config", config, preconfig,
|
||||
api=API_COMPAT)
|
||||
|
||||
def test_init_env(self):
|
||||
def test_init_compat_env(self):
|
||||
preconfig = {
|
||||
'allocator': PYMEM_ALLOCATOR_MALLOC,
|
||||
}
|
||||
config = {
|
||||
'use_hash_seed': 1,
|
||||
'hash_seed': 42,
|
||||
'tracemalloc': 2,
|
||||
'import_time': 1,
|
||||
'malloc_stats': 1,
|
||||
'inspect': 1,
|
||||
'optimization_level': 2,
|
||||
'module_search_path_env': '/my/path',
|
||||
'pycache_prefix': 'env_pycache_prefix',
|
||||
'write_bytecode': 0,
|
||||
'verbose': 1,
|
||||
'buffered_stdio': 0,
|
||||
'stdio_encoding': 'iso8859-1',
|
||||
'stdio_errors': 'replace',
|
||||
'user_site_directory': 0,
|
||||
'faulthandler': 1,
|
||||
'warnoptions': ['EnvVar'],
|
||||
}
|
||||
self.check_config("test_init_compat_env", config, preconfig,
|
||||
api=API_COMPAT)
|
||||
|
||||
def test_init_python_env(self):
|
||||
preconfig = {
|
||||
'allocator': PYMEM_ALLOCATOR_MALLOC,
|
||||
'utf8_mode': 1,
|
||||
|
@ -732,8 +762,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'faulthandler': 1,
|
||||
'warnoptions': ['EnvVar'],
|
||||
}
|
||||
self.check_config("test_init_env", config, preconfig,
|
||||
api=API_COMPAT)
|
||||
self.check_config("test_init_python_env", config, preconfig,
|
||||
api=API_PYTHON)
|
||||
|
||||
def test_init_env_dev_mode(self):
|
||||
preconfig = dict(allocator=PYMEM_ALLOCATOR_DEBUG)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue