Repository navigation
fix(pcap): Header.pack() writes the same magic for every endian/nanosecond setting; _make_data returns magic_number - #1143
Merged
Conversation
…econd setting; _make_data returns magic_number - Header._make_data returned the raw `magic_number`, which make() does not take, so from_data dropped it with a warning and rebuilt every header as the host-order microsecond default (d4c3b2a1 on little-endian hosts). It now returns `byteorder` and `nanosecond`, so from_data(Header(...).info) is byte-identical for all four magics. - A no-argument pack() rebuilding from make() defaults is the contract of every protocol (Ethernet behaves the same), so it is left as is. - Drop the Header entry, the table's only one, from the recorded _make_data mismatches in test_construction_keyword_check_unit. - test_header_frame_unit's stub MagicNumber gains the byteorder and nanosecond fields the real one carries. Closes #1125
Owner
Author
|
Cross-review verdict on
The single-flag cases pass only because both sides ignore a lone flag. That is #1144. |
Contributor
|
Coverage: 88.75% (unit tier, Python 3.14,
Per-file detail: the |
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.
make pylint,make mypy,make isort) — Makefile flags run onheader.pyonly: isort clean, mypy 0 errors in the file, pylint only the existing W0201 on_byte/_nsecmake testpasses, and a test case covers the change — the modules listed below, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1125.
Header._make_datareturnedmagic_number, whichmake()does not accept.from_datadropped it (with anUnknownFieldWarning) and rebuilt every header as the host default,d4c3b2a1. It now returnsbyteorderandnanosecond. Callingpack()with no arguments rebuilds frommake()defaults for every protocol (Ethernet(src=...).pack()does the same), so I left that alone.Probe:
Header.from_data(Header(**kw).info).data == Header(**kw).data, with four byteorder×nanosecond cases plus thelilendian/bigendianflags. Before: only thed4c3b2a1cases match, and every call warns. After: all 8 match with no warnings, and big-endian packsa1b2c3d4 00020004.The new
tests/protocols/misc/pcap/test_header_make_data_magic_unit.pypasses 2 with the fix and fails 5 (incl. subtests) with it reverted. I also deleted the recorded-mismatch test fromtest_construction_keyword_check_unit.py: its only entry was Header's. Andtest_header_frame_unit.py's stubMagicNumbernow carries thebyteorder/nanosecondfields the real one has.Results: new module 2 passed · keyword_check 21 passed · header_magic_protos 3 passed · header_frame 6 passed · option_roundtrip 6 passed ·
tests/project385 passed, 1 skipped.