mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
GH-91173: disable frozen modules in debug builds (#92023)
This commit is contained in:
parent
48c6165c28
commit
e8d7661ff2
3 changed files with 27 additions and 25 deletions
|
@ -22,7 +22,7 @@ if not support.has_subprocess_support:
|
||||||
|
|
||||||
MS_WINDOWS = (os.name == 'nt')
|
MS_WINDOWS = (os.name == 'nt')
|
||||||
MACOS = (sys.platform == 'darwin')
|
MACOS = (sys.platform == 'darwin')
|
||||||
|
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
|
||||||
PYMEM_ALLOCATOR_NOT_SET = 0
|
PYMEM_ALLOCATOR_NOT_SET = 0
|
||||||
PYMEM_ALLOCATOR_DEBUG = 2
|
PYMEM_ALLOCATOR_DEBUG = 2
|
||||||
PYMEM_ALLOCATOR_MALLOC = 3
|
PYMEM_ALLOCATOR_MALLOC = 3
|
||||||
|
@ -478,7 +478,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'pathconfig_warnings': 1,
|
'pathconfig_warnings': 1,
|
||||||
'_init_main': 1,
|
'_init_main': 1,
|
||||||
'_isolated_interpreter': 0,
|
'_isolated_interpreter': 0,
|
||||||
'use_frozen_modules': 1,
|
'use_frozen_modules': not Py_DEBUG,
|
||||||
'_is_python_build': IGNORE_CONFIG,
|
'_is_python_build': IGNORE_CONFIG,
|
||||||
}
|
}
|
||||||
if MS_WINDOWS:
|
if MS_WINDOWS:
|
||||||
|
@ -1177,7 +1177,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
# The current getpath.c doesn't determine the stdlib dir
|
# The current getpath.c doesn't determine the stdlib dir
|
||||||
# in this case.
|
# in this case.
|
||||||
'stdlib_dir': '',
|
'stdlib_dir': '',
|
||||||
'use_frozen_modules': 1,
|
'use_frozen_modules': not Py_DEBUG,
|
||||||
# overridden by PyConfig
|
# overridden by PyConfig
|
||||||
'program_name': 'conf_program_name',
|
'program_name': 'conf_program_name',
|
||||||
'base_executable': 'conf_executable',
|
'base_executable': 'conf_executable',
|
||||||
|
@ -1416,12 +1416,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
config['base_prefix'] = pyvenv_home
|
config['base_prefix'] = pyvenv_home
|
||||||
config['prefix'] = pyvenv_home
|
config['prefix'] = pyvenv_home
|
||||||
config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib')
|
config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib')
|
||||||
config['use_frozen_modules'] = 1
|
config['use_frozen_modules'] = not Py_DEBUG
|
||||||
else:
|
else:
|
||||||
# cannot reliably assume stdlib_dir here because it
|
# cannot reliably assume stdlib_dir here because it
|
||||||
# depends too much on our build. But it ought to be found
|
# depends too much on our build. But it ought to be found
|
||||||
config['stdlib_dir'] = self.IGNORE_CONFIG
|
config['stdlib_dir'] = self.IGNORE_CONFIG
|
||||||
config['use_frozen_modules'] = 1
|
config['use_frozen_modules'] = not Py_DEBUG
|
||||||
|
|
||||||
env = self.copy_paths_by_env(config)
|
env = self.copy_paths_by_env(config)
|
||||||
self.check_all_configs("test_init_compat_config", config,
|
self.check_all_configs("test_init_compat_config", config,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Disable frozen modules in debug builds. Patch by Kumar Aditya.
|
|
@ -732,7 +732,11 @@ _PyConfig_InitCompatConfig(PyConfig *config)
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
config->legacy_windows_stdio = -1;
|
config->legacy_windows_stdio = -1;
|
||||||
#endif
|
#endif
|
||||||
config->use_frozen_modules = -1;
|
#ifdef Py_DEBUG
|
||||||
|
config->use_frozen_modules = 0;
|
||||||
|
#else
|
||||||
|
config->use_frozen_modules = 1;
|
||||||
|
#endif
|
||||||
config->_is_python_build = 0;
|
config->_is_python_build = 0;
|
||||||
config->code_debug_ranges = 1;
|
config->code_debug_ranges = 1;
|
||||||
}
|
}
|
||||||
|
@ -1978,25 +1982,22 @@ config_init_import(PyConfig *config, int compute_path_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -X frozen_modules=[on|off] */
|
/* -X frozen_modules=[on|off] */
|
||||||
if (config->use_frozen_modules < 0) {
|
const wchar_t *value = config_get_xoption_value(config, L"frozen_modules");
|
||||||
const wchar_t *value = config_get_xoption_value(config, L"frozen_modules");
|
if (value == NULL) {
|
||||||
if (value == NULL) {
|
}
|
||||||
config->use_frozen_modules = !config->_is_python_build;
|
else if (wcscmp(value, L"on") == 0) {
|
||||||
}
|
config->use_frozen_modules = 1;
|
||||||
else if (wcscmp(value, L"on") == 0) {
|
}
|
||||||
config->use_frozen_modules = 1;
|
else if (wcscmp(value, L"off") == 0) {
|
||||||
}
|
config->use_frozen_modules = 0;
|
||||||
else if (wcscmp(value, L"off") == 0) {
|
}
|
||||||
config->use_frozen_modules = 0;
|
else if (wcslen(value) == 0) {
|
||||||
}
|
// "-X frozen_modules" and "-X frozen_modules=" both imply "on".
|
||||||
else if (wcslen(value) == 0) {
|
config->use_frozen_modules = 1;
|
||||||
// "-X frozen_modules" and "-X frozen_modules=" both imply "on".
|
}
|
||||||
config->use_frozen_modules = 1;
|
else {
|
||||||
}
|
return PyStatus_Error("bad value for option -X frozen_modules "
|
||||||
else {
|
"(expected \"on\" or \"off\")");
|
||||||
return PyStatus_Error("bad value for option -X frozen_modules "
|
|
||||||
"(expected \"on\" or \"off\")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _PyStatus_OK();
|
return _PyStatus_OK();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue