Skip to content

fix(loopback): reject an address family that is not an int (#2289) - #2364

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2289-loopback-family-type
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2289-loopback-family-type

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2289.

  • Fix: Loopback.make now type-checks family before range-checking it, so a bool or anything else that isn't an int raises the documented ProtocolError instead of True packing as 1 or '2' raising a bare TypeError.
  • Fail-without-fix: 5 failed on origin/main. Passing on the rebased head.

@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: NEEDS CHANGES at 86e7b280b (Sonnet) — one change-relative comment, code is correct.

  • Confirmed: Loopback.make type-checks family before range-checking it (88 cases on both trees); a bool or any non-int raises ProtocolError with the house-form message; 24,144 parse-rebuild cases are byte-identical to origin/main. Fail-without-fix: 5 failed. On the head, 13+121 passed.
  • Required: reword "used to pack as family 1" in the new test comment — change-relative, per the docs: #719-style prose sweep after the #1090–#1102 defect wave #1103 sweep.
  • Non-blocking: the same ESP spi (and a few other range-only guards) have the same latent gap, worth their own issue.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
Loopback.make range-checked family and then called family.to_bytes with
no type check, so True packed as family 1, '2' and None raised TypeError
and 2.0 raised AttributeError.

A bool or any non-int family now raises the documented ProtocolError
"Loopback: invalid address family: ...", from the same check as the
range test.

Test: test_make_rejects_a_family_that_is_not_an_int pins the message for
True, False, '2', 2.0 and None.
@JarryShaw
JarryShaw force-pushed the fix/2289-loopback-family-type branch from 86e7b28 to 3144adc Compare October 27, 2026 04:09
@JarryShaw

Copy link
Copy Markdown
Owner Author

Amended 86e7b280b → 3144adc16: reworded the test comment to state the behaviour rather than its history. test_loopback_unit.py + test_docstring_contract.py give 21 passed.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.58% (unit tier, Python 3.15, 3144adc16, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 881 2618 867 92.11%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3029 23 1050 25 98.82%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17442 218 4586 185 98.15%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4432 1988 1018 167 51.87%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 3144adc16. Closes #2289.

  • Review: NEEDS CHANGES → fixed (change-relative test comment) → self-certified, prose-only change.
  • CI: Required checks passed SUCCESS, 0 failures, KTLO clean.
  • Ordering leg: protocols gave 1969 tests with 0 failures, run with the PR merged into current main.
  • Merge state: mergeable.

@JarryShaw
JarryShaw merged commit 57b7808 into main Oct 27, 2026
63 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(loopback): make() never type-checks family, so True packs 1 and '2' raises TypeError

1 participant