Repository navigation
fix(corekit): ProtoChain.__add__ returns stale protocols/aliases - #1107
Merged
Merged
Conversation
__add__ built its result with copy.copy(self), which carried the left operand's cached protocols/aliases into the merged chain. Build a fresh instance through __new__ instead, as from_list does, and drop the now unused copy import. __add__ is the only method that copies the chain; a += b falls back to it and rebinds. Closes #1099
Owner
Author
|
Cross-review verdict on
Nit: a subclass whose |
Contributor
|
Coverage: 88.74% (unit tier, Python 3.14,
Per-file detail: the |
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.
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort). Ran isort, pylint and mypy directly on the touched file instead: isort is clean, mypy reports nothing inprotochain.py, and pylint's two findings (:57,:194) are on existing lines.make testpasses, and a test case covers the change (only these modules: the new one,tests/corekit/test_protochain.pyandtests/project)Added a changelog entry, N/A: added centrally after the wave
fix— corrects a defectCloses #1099.
__add__usedcopy.copy(self), which carried the left operand's cachedprotocols/aliasesinto the result. It now builds a fresh instance through__new__, asfrom_listdoes.__add__is the only method that copies the chain, anda += bfalls back to it.Probe (
a = ProtoChain(Ethernet); a.protocols; b = a + ProtoChain(IPv4)):b.chain == 'Ethernet:IPv4', butb.protocols == (Ethernet,)andb.aliases == ('Ethernet',)b.protocols == (Ethernet, IPv4),b.aliases == ('Ethernet', 'IPv4'), andais unchangedTests in
tests/corekit/test_protochain_add_stale_cache_1099_unit.py:2 failed, 1 passed. The warm-cache and+=cases fail. The cold-cache case is a control and passes either way.3 passed.test_protochain.pygives4 passed, andtests/projectgives379 passed, 1 skipped, 1285 subtests passed.