Repository navigation
Conversation
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 mypyc/mypyc#1232.
With separate compilation, adding
@mypyc_attr(native_class=False)to a class between builds, or removing it, didn't recompile the modules that use the class if its module already importedmypyc_attr. Mypy doesn't record the decorator, so the module's interface hash didn't change. The stale modules then failed to compile against the class's new export table ('CPyDef_a___C': is not a member of 'export_table_a').@traithad the same problem, and there the result was a segfault: the trait's module looked for a trait vtable that the stale subclasses didn't have.This is the follow-up mentioned in #22128, using the same approach.
MypycPlugin.report_config_datanow returns(name, is_ext_class, is_trait, is_decorated)for each class in the module, in place of the list of decorated class names that #22128 added, and mypy includes the plugin config data in the interface hash. When the cache is written, these come from the tree, using the sameis_extension_class,is_traitandis_decorated_classcalls asbuild_type_map. When the cache is checked, the module hasn't been parsed yet, so they come from the cached IR.The new tests turn each decorator on and off. A step in the middle changes only
native.pyand checks thatother, which then has a non-native class or a trait, stays fresh, so a mismatch between the write and check paths would show up.Other
mypyc_attrflags that affect subclasses in other modules, such asserializable, have the same gap. I left them out since they'd mean repeating howprepare_class_defderives them, but I can add them here if you'd like.