Save and restore working_set in include_subclasses#726
Open
bysiber wants to merge 1 commit intopython-attrs:mainfrom
Open
Save and restore working_set in include_subclasses#726bysiber wants to merge 1 commit intopython-attrs:mainfrom
bysiber wants to merge 1 commit intopython-attrs:mainfrom
Conversation
When include_subclasses is called from within a structure hook factory (which is itself invoked during make_dict_structure_fn), it would overwrite already_generating.working_set with its own set and then reset it to an empty set. This caused the outer make_dict_structure_fn to fail with AttributeError when trying to clean up its working_set. Now the existing working_set is saved before the loop and restored after, so nested calls work correctly.
Member
|
Hello, I believe this is already being fixed in #722 , right? |
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.
When
include_subclassesis called from within a structure hook factory (which itself runs duringmake_dict_structure_fn), it overwritesalready_generating.working_setwith its own set and then resets it to an empty set. This breaks the outermake_dict_structure_fnwhich still expects to clean up its own working_set, causingAttributeError: working_set.The fix saves the existing
working_setbefore the loop and restores it after, so nested generation contexts work correctly.Added a regression test that reproduces the exact scenario from #721.
Fixes #721