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
This commit is contained in:
Eric Snow 2021-09-14 17:31:45 -06:00 committed by GitHub
parent 1aaa859497
commit a65c86889e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 359 additions and 117 deletions

View file

@ -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]*/