Skip to content

Commit 6946b19

Browse files
Default to "on" if a non-debug build.
1 parent ae7839b commit 6946b19

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Lib/test/support/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
STDLIB_DIR = os.path.dirname(TEST_HOME_DIR)
107107
REPO_ROOT = os.path.dirname(STDLIB_DIR)
108108

109+
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
110+
109111

110112
class Error(Exception):
111113
"""Base class for regression test exceptions."""

Lib/test/test_embed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
434434
'pathconfig_warnings': 1,
435435
'_init_main': 1,
436436
'_isolated_interpreter': 0,
437-
'use_frozen_modules': 0,
437+
'use_frozen_modules': 0 if support.Py_DEBUG else 1,
438438
}
439439
if MS_WINDOWS:
440440
CONFIG_COMPAT.update({

Python/initconfig.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,9 +2089,12 @@ config_init_import(PyConfig *config, int compute_path_config)
20892089
/* -X frozen_modules=[on|off] */
20902090
const wchar_t *value = config_get_xoption_value(config, L"frozen_modules");
20912091
if (value == NULL) {
2092-
// For now we always default to "off".
2093-
// In the near future we will be factoring in PGO and in-development.
2092+
// Default to "off" on debug builds and "on" otherwise.
2093+
#ifdef Py_DEBUG
20942094
config->use_frozen_modules = 0;
2095+
#else
2096+
config->use_frozen_modules = 1;
2097+
#endif
20952098
}
20962099
else if (wcscmp(value, L"on") == 0) {
20972100
config->use_frozen_modules = 1;

0 commit comments

Comments
 (0)