Skip to content

refactor(pcapng)!: rename PCAPNG.context to section_context (#2172) - #2205

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2172-pcapng-section-context
Oct 25, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2172-pcapng-section-context

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — restructures code without changing intended behaviour

Description

Closes #2172. The owner picked option 1, so the PCAP-NG property is renamed and no longer collides with ProtocolBase.context.

  • Breaking: PCAPNG.context returned the block's section Context in 1.3.x and 1.4.x. It is renamed section_context, with no alias, and it still raises UnsupportedCall on a Section Header Block. PCAPNG.context now falls back to ProtocolBase.context, which is the caller-supplied ContextRegistry.
  • Docs: a versionchanged:: 1.5.0 note on the PCAPNG class tells 1.4.x users where the section context went. section_context carries versionadded:: 1.5.0, and pcapng.rst documents it.
  • Tests:
    • The SHB-raises and section-context tests in test_pcapng_unit.py read section_context.
    • A new test checks that, on an SHB and an EPB, context is a fresh ContextRegistry copy that equals the base property's value.
    • On main, 3 fail: the old SHB test, the new test, and its section_context subtest.
  • Tests run: the PCAP-NG unit, round-trip and engine tests, the protocol base tests, the docstring contract and the tier guard pass (390). The docs xref tests pass under the pinned docs venv (48).
  • Callers: nothing in pcapkit/, docs/ or examples/ read the old property.

PCAPNG.context overrode ProtocolBase.context with a different type: it
returned the block's section Context (raising UnsupportedCall on a Section
Header Block), so a PCAP-NG block could not reach the caller supplied
ContextRegistry. This breaks the property as released in 1.4.x.

Rename the property to section_context, with no alias, so context falls
back to the base contract. A versionchanged note on PCAPNG tells 1.4.x
users where the section context went; pcapng.rst documents
section_context.

Tests: the SHB-raises and section-context assertions read section_context;
a new test checks PCAPNG.context returns the base ContextRegistry copy of
_exctx on both a Section Header Block and a packet block.
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 25, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at ab635277f (Sonnet).

  • No alias: nothing aliases or shims the old name.
  • Base context: context now returns a fresh ContextRegistry copy on SHB and EPB blocks alike.
  • Callers: nothing in pcapkit/, docs/, examples/ or tests/ reads the old property.
  • Notes: the class note and the property note agree.
  • On main: 3 of the new tests fail; the PR body now says so.
  • breaking: warranted, since context silently changes type for 1.4.x callers.
  • Changelog: a migration line in the 1.5.0 changelog is logged as a follow-up.

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

Copy link
Copy Markdown
Contributor

Coverage: 91.55% (unit tier, Python 3.15, ab635277f, 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 2971 23 1036 25 98.80%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17433 218 4584 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 ab635277f. Closes #2172 (option 1, re-confirmed by the owner). Labelled breaking: PCAPNG.context is renamed to section_context with no alias.

  • Review: Sonnet GOOD TO GO, first round.
  • CI: all checks complete, Required checks passed SUCCESS, 0 failed.
  • KTLO: 12 legs, no warnings.
  • Ordering: the protocols leg was merged into main and run: 1924 tests, 0 failures.
  • Conflicts: none against the current main.

@JarryShaw
JarryShaw merged commit 7e8cec0 into main Oct 25, 2026
66 checks passed
@JarryShaw
JarryShaw deleted the fix/2172-pcapng-section-context branch October 25, 2026 21:33
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 25, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 25, 2026
JarryShaw added a commit that referenced this pull request Oct 25, 2026
- Add 1.5.0 entries for the round-5 merges with user-visible effect:
  the breaking PCAPNG.context rename to section_context (#2172, #2205)
  with its migration line; the registrar code check (#2186); the corekit
  exports and ListField/SchemaField copy fixes (#2174, #2173); and the
  ARP, Quick-Start/Fast Open, PCAP-NG, IPX, HIP and message fixes
  (#2166-#2171).
- Correct the systemd journal entries (#678, #704, #723, #794) to the
  strict walk: a malformed entry keeps the block as captured (#1406).
- Restate entries without review/CI process narrative or "unfixed tree".
- Extend the intro's cited range to #2205; regenerate CHANGELOG.md.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
JarryShaw added a commit that referenced this pull request Oct 26, 2026
- Add 1.5.0 entries for the round-5 merges with user-visible effect:
  the breaking PCAPNG.context rename to section_context (#2172, #2205)
  with its migration line; the registrar code check (#2186); the corekit
  exports and ListField/SchemaField copy fixes (#2174, #2173); and the
  ARP, Quick-Start/Fast Open, PCAP-NG, IPX, HIP and message fixes
  (#2166-#2171).
- Correct the systemd journal entries (#678, #704, #723, #794) to the
  strict walk: a malformed entry keeps the block as captured (#1406).
- Restate entries without review/CI process narrative or "unfixed tree".
- Extend the intro's cited range to #2205; regenerate CHANGELOG.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

design(protocols): PCAPNG.context shadows ProtocolBase.context with a different type

1 participant