Skip to content

fix(pcap): a lone lilendian/bigendian flag is ignored by Header._make_magic - #1159

Merged
JarryShaw merged 1 commit into
mainfrom
fix-1144-pcap-header-lone-endian
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix-1144-pcap-header-lone-endian

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort) — ran pylint/mypy on header.py: nothing on the changed lines; isort flags header.py and test_header_frame_unit.py identically on main (imports untouched)
  • make test passes, and a test case covers the change — the modules listed below only
  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible — N/A, added centrally after the wave

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

Closes #1144. Header._make_magic honoured lilendian/bigendian only as a pair. Now either flag on its own picks the byte order and overrides byteorder. Equal flags still raise EndianError. Builds on #1143.

Probe on little-endian host, Header(**kw).data[:4], before → after: bigendian=True d4c3b2a1 → a1b2c3d4; lilendian=False d4c3b2a1 → a1b2c3d4.

New tests/protocols/misc/pcap/test_header_lone_endian_flag_unit.py: 4 subtests fail without the fix, all pass with it. test_header_frame_unit.py:149 asserted the old behaviour (byteorder='big', bigendian=False → big), so I updated that one assertion.

Passing: the new module, test_header_frame_unit, test_header_magic_protos_unit, test_header_make_data_magic_unit, test_frame_endian_runtime, test_frame_runtime, test_construction_keyword_check_unit, test_option_roundtrip_unit, tests/project (389 passed, 1 skipped).

…_magic

_make_magic honoured the endian flags only when both were given, so
Header(bigendian=True) fell back to byteorder (the host order). Either
flag alone now selects the byte order and overrides byteorder; equal
flags still raise EndianError.

test_header_frame_unit pinned the old behaviour (bigendian=False losing
to byteorder='big') and is updated. New regression module:
tests/protocols/misc/pcap/test_header_lone_endian_flag_unit.py.

Closes #1144
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 6, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on 135126cfc: GOOD TO GO (ran on Sonnet; author Opus)

  • Semantics confirmed: each lone flag now chooses its byte order and overrides byteorder (bigendian=False → d4c3b2a1, lilendian=False → a1b2c3d4). Passing both flags is unchanged, and equal flags still raise EndianError.
  • No caller affected: nothing in pcapkit/ passes a lone flag. dumpkit/pcap.py:140, foundation/extraction.py:1164 and traceflow/tcp.py:273 forward only byteorder and nanosecond. I re-grepped this myself.
  • Edited assertion (test_header_frame_unit.py:149): it pinned an accident, not a contract. It came from the bulk coverage commit 78e28d811 and fed a non-bool lilendian=''.
  • Fails without the fix: with header.py reverted, 4 lone-flag subtests fail. The test is host-independent, since every case sets byteorder opposite to the flag.
  • Not breaking: the docstrings on main never said the flags must be paired, and both default to None. Labelled fix only.
  • Nits, not blocking: no case covers a lone flag with nanosecond=True (probed manually: a1b23c4d, correct). The pylint/mypy/isort claims are unverified.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Coverage: 88.86% (unit tier, Python 3.14, 135126cfc, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18757 1035 2342 846 90.23%
pcapkit/corekit 1878 91 580 22 94.34%
pcapkit/dumpkit 142 0 42 0 100.00%
pcapkit/foundation 2422 104 842 40 94.24%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 15687 188 3958 163 98.18%
pcapkit/toolkit 487 65 144 1 85.42%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2359 1006 158 42.84%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 6e71d55 into main Oct 7, 2026
41 checks passed
@JarryShaw
JarryShaw deleted the fix-1144-pcap-header-lone-endian branch October 7, 2026 00:16
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 7, 2026
JarryShaw added a commit that referenced this pull request Oct 7, 2026
- 4 new 1.5.0 entries: HTTP/2 sample stream identifiers (#1161),
  TCP option re-padding (#1163, breaking), format='pcap' output
  (#1164), declared lengths on truncated captures (#1166, breaking)
- extend the PCAP Header (#1159), HIP (#1160) and from_data
  round-trip (#1162) entries rather than duplicating them
- regenerate CHANGELOG.md with util/changelog_md.py
- process.rst: entry-count pin re-measured, 189 -> 193

tests/project: conventions_doc_claims, changelog_md and
documentation_claims pass; changelog_md.py --check is in step.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(pcap): a lone lilendian/bigendian flag is ignored by Header._make_magic

1 participant