Skip to content

fix(foundation): warn when PyPCAP, PCAP_CT or PyPCAPFile ignores Extractor(context=) (#2313) - #2332

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2313-engines-warn-on-context
Oct 26, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2313-engines-warn-on-context

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2313, per the ruling (option 1).

  • Fix:
    • PyPCAP, PCAP_CT and PyPCAPFile run() now warn AttributeWarning when Extractor(context=…) is given, in the same wording DPKT, Scapy and PyShark use.
    • Each Warns: section lists it.
  • Test: each engine's test file gains a case that passes a non-empty _exctx and checks the exact warning. The fixtures carry _exctx: {}, so the threshold tests also show that an empty context stays silent.
  • Fail-without-fix: on origin/main, 3 failed (AssertionError: 0 != 1).
  • Tests run: the engine and adapter tests, the tier guard and the docstring contract give 244 passed.

…actor(context=) (#2313)

Problem: the DPKT, Scapy and PyShark engines warn that a parsing context
supplied through 'context=' is ignored, but the PyPCAP, PCAP_CT and
PyPCAPFile engines never read Extractor._exctx and drop it silently.

Fix: each of the three engines' run() emits the same AttributeWarning,
naming the engine, right after its layer/protocol threshold warning, and
lists it under Warns: as DPKT and Scapy do.

Test: each engine's unit test drives run() with a non-empty _exctx and
pins the exact warning; the shared fixtures gain an empty _exctx, so the
threshold tests' call counts also pin that no context stays silent.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 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 26, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at 0e8550c8e (Sonnet).

  • Behaviour: the warning is AttributeWarning with DPKT/Scapy/PyShark's wording, and fires only for a non-empty _exctx. An empty registry or {} stays silent, which the threshold tests pin.
  • Tests: they call the real engine.run(), with only warn patched; call_count == 1, the exact message and the class are asserted.
  • Fail-without-fix: on origin/main, 3 failed (AssertionError: 0 != 1). On the head, the engine tests and the docstring contract give 83 passed.

@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 26, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.56% (unit tier, Python 3.15, 0e8550c8e, 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 2589 74 816 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 17437 218 4586 185 98.15%
pcapkit/toolkit 869 36 298 10 95.20%
pcapkit/utilities 504 7 146 5 98.15%
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 0e8550c8e. Closes #2313.

  • Review: GOOD TO GO (Sonnet).
  • CI: every check passed, Required checks passed included. The experimental legs are green, and KTLO shows no warnings.
  • Ordering leg: foundation gave 748 tests with 0 failures, run with the PR merged into 2d8c8b516.
  • Merge state: mergeable. It is BEHIND only because of main's test-only pushes since then, and no file overlaps.

@JarryShaw
JarryShaw merged commit 1b2f9f1 into main Oct 26, 2026
68 checks passed
@JarryShaw
JarryShaw deleted the fix/2313-engines-warn-on-context branch October 26, 2026 23:39
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 26, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 26, 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(foundation): PyPCAP, PCAP_CT and PyPCAPFile engines drop Extractor(context=) silently

1 participant