Repository navigation
fix(corekit): pass the copy to ListField callbacks and size SchemaField templates from it (#2173) - #2190
Merged
Conversation
…ld templates from it (#2173) ListField.__call__ passed its callback the template instead of the copy it returns, so a callback adjusting its field would mutate the shared template. SchemaField.__call__ tested the template's -1 length when sizing the copy's template, so a callable length always left it at '1024s'. Both now read new_self, as Field.__call__ does. Test: tests/corekit/test_fields_call_new_self_2173_unit.py checks callback identity, an untouched template across two calls, and a '24s' template; three of its four tests fail without the fix.
Owner
Author
|
Review: GOOD TO GO at |
Owner
Author
|
Ready to merge at
|
Contributor
|
Coverage: 91.55% (unit tier, Python 3.15,
Per-file detail: the |
5 tasks done
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.
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription
Closes #2173.
ListField.__call__copied itself and then rannew_self._callback(self, packet), so the callback mutated the shared template, not the copy.SchemaField.__call__chose the copy's template fromself._length, which is always -1 when the length is a callable, so it always fell back to1024s.new_self.tests/corekit/test_fields_call_new_self_2173_unit.py. Onmainit fails 3 tests: the callback receives the template, the template is mutated, and'1024s' != '24s'.