Repository navigation
fix(corekit)!: to_dict() returns an InfoDict, so a repeated IPv6 extension header survives the dict rebuild (#1453) - #1466
Merged
Conversation
Contributor
|
Coverage: 89.56% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Verdict: NEEDS CHANGES at
Holds:
Notes:
|
…nsion header survives the dict rebuild (#1453) to_dict() keyed the extension headers by name, so a second header of the same type overwrote the first and from_data(info.to_dict()) rebuilt a shorter packet: Destination Options twice, then UDP, came back 56 of 64. - multidict: new InfoDict, an OrderedMultiDict with dict views and dict equality; the dict interface sees the first value per key. - Info: to_dict() returns an InfoDict. __update__ given a MultiDict adds to a key already held instead of replacing it, and items(multi=True) yields every value in order. A copy.copy() gets its own bookkeeping. - IPv6: each extension header is added through a MultiDict, and _lookup_exthdr walks items(multi=True). - dumpkit: an InfoDict is written as a mapping, not as the entry list an OrderedMultiDict field gets, so every dump stays byte-identical. - docs: InfoDict in the multidict page. Legs corekit, foundation, dumpkit, protocols/internet, protocols (rest) and project pass; the capture dumps are byte-identical to main.
JarryShaw
force-pushed
the
fix/1453-to-dict-multidict
branch
from
October 9, 2026 04:23
dd2029c to
074e0c8
Compare
Owner
Author
|
Verdict: GOOD TO GO at
Optional additions to the breaking-changes list, not blockers:
|
Merged
3 of 5 tasks
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.
isort -l100 -ppcapkitclean;pylint/mypy(Makefile flags) on the 4 modules: no new findings in the changed linesmake testpasses, and a test case covers the change — on94ae9664c: legscorekit633,dumpkit232,protocols/internet617,project606, all OK; new module 7 passed, 41 subtestsWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1453
to_dict()now returnsInfoDict, a newOrderedMultiDictsubclass, for everyInfo, so the return type does not depend on the packet. Thedictinterface,jsonand the dumpers see the first value per key, anditems(multi=True)yields every value in wire order.Info.__update__given aMultiDictadds to a key it already holds, IPv6 adds each extension header that way, and_lookup_exthdrwalksitems(multi=True).Breaking (
!), for callers ofto_dict():type(d) is dictis now False (isinstance(d, dict)still holds).d == plain_dictis False when a key repeats.yaml.safe_dump(d)raisesRepresenterError.d[key],info.optsand the dumps.Also touched: the
InfoDictdocs entry, andpcapkit/dumpkit/common.py, whoseobject_hookwrites anyOrderedMultiDictas a list of entries; one condition now sends anInfoDictto thedictbranch, so all 92 dumps (23 captures × json/tree/plist/xml) are byte-identical tomainat94ae9664c.Dict rebuilds before → after: dst-dst 56→64/64, hop-dst-dst 64→72, dst-dst-dst 56→72, Routing-Routing 56→64, dst-rt-dst 56→72, hop-dst-rt-dst 64→80. Byte-exact through Ethernet and Frame too.
copy.copy(info)now gets its own__multi__. Withmain's sources, the newtests/protocols/test_to_dict_repeated_exthdr_1453_unit.pyreports 34 failed, 3 passed; with this PR, 7 passed, 41 subtests.