aboutsummaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-09-14 17:31:45 -0600
committerGitHub <noreply@github.com>2021-09-14 17:31:45 -0600
commita65c86889e208dddb26a7ebe7840c24edbcca775 (patch)
treeec55222c3ac183806fc06f0d60514ab21e6dc560 /Include
parent1aaa85949717e4ab2ed700e58762f0a3ce049a37 (diff)
downloadcpython3-a65c86889e208dddb26a7ebe7840c24edbcca775.tar.gz
bpo-45020: Add -X frozen_modules=[on|off] to explicitly control use of frozen modules. (gh-28320)
Currently we freeze several modules into the runtime. For each of these modules it is essential to bootstrapping the runtime that they be frozen. Any other stdlib module that we later freeze into the runtime is not essential. We can just as well import from the .py file. This PR lets users explicitly choose which should be used, with the new "-X frozen_modules=[on|off]" CLI flag. The default is "off" for now. https://bugs.python.org/issue45020
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/initconfig.h1
-rw-r--r--Include/internal/pycore_initconfig.h1
-rw-r--r--Include/internal/pycore_interp.h3
3 files changed, 5 insertions, 0 deletions
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index 22ad0f14e5..65d52c4578 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -172,6 +172,7 @@ typedef struct PyConfig {
int legacy_windows_stdio;
#endif
wchar_t *check_hash_pycs_mode;
+ int use_frozen_modules;
/* --- Path configuration inputs ------------ */
int pathconfig_warnings;
diff --git a/Include/internal/pycore_initconfig.h b/Include/internal/pycore_initconfig.h
index 4b009e816b..9014fcd41d 100644
--- a/Include/internal/pycore_initconfig.h
+++ b/Include/internal/pycore_initconfig.h
@@ -155,6 +155,7 @@ extern PyStatus _PyConfig_Copy(
extern PyStatus _PyConfig_InitPathConfig(
PyConfig *config,
int compute_path_config);
+extern PyStatus _PyConfig_InitImportConfig(PyConfig *config);
extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config);
extern PyStatus _PyConfig_Write(const PyConfig *config,
struct pyruntimestate *runtime);
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index bfd082b588..0e6edf4ec2 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -246,6 +246,9 @@ struct _is {
PyObject *builtins;
// importlib module
PyObject *importlib;
+ // override for config->use_frozen_modules (for tests)
+ // (-1: "off", 1: "on", 0: no override)
+ int override_frozen_modules;
/* Used in Modules/_threadmodule.c. */
long num_threads;