diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2021-09-14 23:31:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 23:31:45 (GMT) |
commit | a65c86889e208dddb26a7ebe7840c24edbcca775 (patch) | |
tree | ec55222c3ac183806fc06f0d60514ab21e6dc560 /Python/clinic | |
parent | 1aaa85949717e4ab2ed700e58762f0a3ce049a37 (diff) | |
download | cpython-a65c86889e208dddb26a7ebe7840c24edbcca775.zip cpython-a65c86889e208dddb26a7ebe7840c24edbcca775.tar.gz cpython-a65c86889e208dddb26a7ebe7840c24edbcca775.tar.bz2 |
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 'Python/clinic')
-rw-r--r-- | Python/clinic/import.c.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h index ec4ebca..438a348 100644 --- a/Python/clinic/import.c.h +++ b/Python/clinic/import.c.h @@ -315,6 +315,37 @@ _imp__frozen_module_names(PyObject *module, PyObject *Py_UNUSED(ignored)) return _imp__frozen_module_names_impl(module); } +PyDoc_STRVAR(_imp__override_frozen_modules_for_tests__doc__, +"_override_frozen_modules_for_tests($module, override, /)\n" +"--\n" +"\n" +"(internal-only) Override PyConfig.use_frozen_modules.\n" +"\n" +"(-1: \"off\", 1: \"on\", 0: no override)\n" +"See frozen_modules() in Lib/test/support/import_helper.py."); + +#define _IMP__OVERRIDE_FROZEN_MODULES_FOR_TESTS_METHODDEF \ + {"_override_frozen_modules_for_tests", (PyCFunction)_imp__override_frozen_modules_for_tests, METH_O, _imp__override_frozen_modules_for_tests__doc__}, + +static PyObject * +_imp__override_frozen_modules_for_tests_impl(PyObject *module, int override); + +static PyObject * +_imp__override_frozen_modules_for_tests(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int override; + + override = _PyLong_AsInt(arg); + if (override == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _imp__override_frozen_modules_for_tests_impl(module, override); + +exit: + return return_value; +} + #if defined(HAVE_DYNAMIC_LOADING) PyDoc_STRVAR(_imp_create_dynamic__doc__, @@ -467,4 +498,4 @@ exit: #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=0ab3fa7c5808bba4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=96038c277119d6e3 input=a9049054013a1b77]*/ |