Currently custom modules (the array set on PyImport_FrozenModules) replace all the frozen stdlib modules. That can be problematic and is unlikely to be what the user wants. This change treats the custom frozen modules as additions instead. They take precedence over all other frozen modules except for those needed to bootstrap the import system. If the "code" field of an entry in the custom array is NULL then that frozen module is treated as disabled, which allows a custom entry to disable a frozen stdlib module.
This change allows us to get rid of is_essential_frozen_module() and simplifies the logic for which frozen modules should be ignored.
I don't have examples, other than that PyImport_FrozenModules is what Tools/freeze/makefreeze.py uses. (Given @malemburg's requests elsewhere, Tools/freeze appears to be used in the wild.) The division between the kinds of frozen modules I introduce here allows us to simplify some of the logic in import.c, so I consider it worth doing regardless of any benefit to projects that set custom frozen modules. The only catch is that the existence of PyImport_FrozenModules complicates matters if we leave it as an override instead of making it additions.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
Currently custom modules (the array set on
PyImport_FrozenModules
) replace all the frozen stdlib modules. That can be problematic and is unlikely to be what the user wants. This change treats the custom frozen modules as additions instead. They take precedence over all other frozen modules except for those needed to bootstrap the import system. If the "code" field of an entry in the custom array is NULL then that frozen module is treated as disabled, which allows a custom entry to disable a frozen stdlib module.This change allows us to get rid of
is_essential_frozen_module()
and simplifies the logic for which frozen modules should be ignored.https://bugs.python.org/issue45395
The text was updated successfully, but these errors were encountered: