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

@ -480,6 +480,12 @@ Miscellaneous options
objects and pyc files are desired as well as supressing the extra visual
location indicators when the interpreter displays tracebacks. See also
:envvar:`PYTHONNODEBUGRANGES`.
* ``-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.
Note that the "importlib_bootstrap" and "importlib_bootstrap_external"
frozen modules are always used, even if this flag is set to "off".
It also allows passing arbitrary values and retrieving them through the
:data:`sys._xoptions` dictionary.
@ -518,6 +524,9 @@ Miscellaneous options
.. versionadded:: 3.11
The ``-X no_debug_ranges`` option.
.. versionadded:: 3.11
The ``-X frozen_modules`` option.
Options you shouldn't use
~~~~~~~~~~~~~~~~~~~~~~~~~