Skip to content

fix(dumpkit): call super() without type(self) in make_dumper's object_hook (#2144) - #2146

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2144-make-dumper-super
Oct 24, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2144-make-dumper-super

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

Closes #2144.

  • Fix: make_dumper's DictDumper.object_hook fallback calls super().object_hook(o) instead of super(type(self), self).object_hook(o), which recursed forever in any subclass.
  • Nothing else needed changing: no other super(type(self), …) / super(self.__class__, …) exists in pcapkit/. The three super(<FixedClass>, self) calls (in infoclass.py, fields/numbers.py and schema/misc/pcapng.py) skip a class on purpose, and cannot recurse.
  • Tests: tests/dumpkit/test_make_dumper_subclass_2144_unit.py covers JSON, PLIST, Tree, PCAPIO and NotImplementedIO. For each, a subclass, a sub-subclass, and an override calling super() must all fall through. Without the fix, 15 fail with RecursionError. The dumpkit ordering leg gives 298 tests, 0 failures.

…_hook (#2144)

In a subclass of the class make_dumper returns, type(self) is the subclass, so the fallback resolved back to the same object_hook and recursed until RecursionError. Zero-argument super() binds through the __class__ cell instead. Adds a test subclassing make_dumper's class for every output it is handed.
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 24, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 24, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 660816df1 (Sonnet review).

  • Fix: zero-argument super() is valid in a class body nested in a function, and DictDumper already uses it in __call__, _append_dict, _append_array and _append_number. For the unsubclassed class, the old and new calls resolve to the same next class in the MRO.
  • No other recursive sites: no other super(type(self)…) / super(self.__class__…) exists in pcapkit/. The fixed-class super(Info, self) / super(EnumField, self) calls skip a class on purpose.
  • Tests: with common.py reverted, the new tests fail 15 subtests with RecursionError, and pass with the fix. The dumpkit ordering leg gives 298 tests, 0 failures.

@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 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.55% (unit tier, Python 3.15, 660816df1, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 880 2618 866 92.12%
pcapkit/corekit 2589 75 816 37 96.48%
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 17418 219 4574 185 98.14%
pcapkit/toolkit 869 36 298 10 95.20%
pcapkit/utilities 498 7 144 5 98.13%
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 660816df1.

  • Review: the Sonnet review is GOOD TO GO.
  • CI: every blocking check passed (Required checks passed SUCCESS). The 3.8–3.10 KTLO legs carry no warnings.
  • Ordering: the head sits directly on main d7aa41535, and its tests/dumpkit plain-unittest ordering leg ran 298 tests with 0 failures.

This closes #2144.

@JarryShaw
JarryShaw merged commit 02161e2 into main Oct 24, 2026
67 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 24, 2026
@JarryShaw
JarryShaw deleted the fix/2144-make-dumper-super branch October 24, 2026 15:15
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 24, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone 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)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(dumpkit): make_dumper's object_hook recurses forever in a subclass

1 participant