Skip to content
Merged
Prev Previous commit
Next Next commit
Default to "off" if in development.
  • Loading branch information
ericsnowcurrently committed Oct 14, 2021
commit 03d7d2609f474ab28a6e948bb228b08cc99874bc
3 changes: 2 additions & 1 deletion Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ Miscellaneous options
* ``-X frozen_modules`` determines whether or not frozen modules are
ignored by the import machinery. A value of "on" means they get
imported and "off" means they are ignored. The default is "on"
for non-debug builds (the normal case) and "off" for debug builds.
if this is an installed Python (the normal case). If it's under
development (running from the source tree) then the default is "off".
Note that the "importlib_bootstrap" and "importlib_bootstrap_external"
frozen modules are always used, even if this flag is set to "off".

Expand Down
9 changes: 7 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'pathconfig_warnings': 1,
'_init_main': 1,
'_isolated_interpreter': 0,
'use_frozen_modules': 0,
'use_frozen_modules': GET_DEFAULT_CONFIG,
}
if MS_WINDOWS:
CONFIG_COMPAT.update({
Expand Down Expand Up @@ -1265,7 +1265,9 @@ def test_init_setpythonhome(self):
'stdlib_dir': stdlib,
}
self.default_program_name(config)
env = {'TESTHOME': home, 'PYTHONPATH': paths_str}
env = {'TESTHOME': home,
'PYTHONPATH': paths_str,
'_PYTHONTESTFROZENMODULES': '1'}
self.check_all_configs("test_init_setpythonhome", config,
api=API_COMPAT, env=env)

Expand Down Expand Up @@ -1355,6 +1357,9 @@ def test_init_pyvenv_cfg(self):
'base_executable': executable,
'executable': executable,
'module_search_paths': paths,
# The current getpath.c doesn't determine the stdlib dir
# in this case.
'stdlib_dir': None,
}
path_config = {}
if MS_WINDOWS:
Expand Down
4 changes: 1 addition & 3 deletions Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -2103,9 +2103,7 @@ config_init_import(PyConfig *config, int compute_path_config)
/* -X frozen_modules=[on|off] */
const wchar_t *value = config_get_xoption_value(config, L"frozen_modules");
if (value == NULL) {
// For now we always default to "off".
// In the near future we will be factoring in PGO and in-development.
config->use_frozen_modules = 0;
config->use_frozen_modules = _Py_IsDevelopmentEnv();
}
else if (wcscmp(value, L"on") == 0) {
config->use_frozen_modules = 1;
Expand Down