Repository navigation
Preserve importable ModuleType subclass references on CPython - #611
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #397.
The module reducer uses exact-type dispatch, so a ModuleType subclass used as a
global can prevent a function from being pickled by value. On CPython, let an
importable subclass with default reduction hooks use the existing module
reference reducer. Exact custom dispatch and custom reduction hooks retain their
precedence, including modules whose custom attribute access must not be inspected.
Unregistered and explicitly by-value subclasses remain unsupported rather than
being flattened into ordinary modules.
Regressions cover protocols 2/4/5, direct modules and function globals, custom
dispatch/hooks, and fresh-process import success and missing-module failure.
Validation on Windows:
unchanged runtime, the new cases have 9 failures and 66 passes.
wheel installs; the original dump/load reproducer and reducer-control matrix pass.
Native ROOT, Dask/Optuna integration, PyPy and other platforms were not tested.