Skip to content

fix(corekit): before Python 3.10 an Info subclass with no annotations of its own inherits Info's, so its generated __init__ takes the wrong arguments #1692

Closed

Description

@JarryShaw

Describe the bug
pcapkit/corekit/infoclass.py:170 reads cls_.__annotations__ for each class in the MRO.

Before Python 3.10 (bpo-43901), a class body with no annotations has no __annotations__ of its own, so the lookup returns the nearest base's. For a direct Info subclass that is Info's own __finalised__, __additional__ and __excluded__.

The generated constructor therefore differs by version:

Python generated __init__
3.6–3.9 (self, __finalised__, __additional__, __excluded__)
3.10+ (self, dict_=None, **kwargs)

Building such a subclass from a mapping raises TypeError on 3.6–3.9.

Reproduction
Three tests fail on both legs:

  • tests/corekit/test_infoclass.py::InfoClassTests::test_auto_finalised_info_mapping_update_and_builtin_key_remapping: __init__() got an unexpected keyword argument 'extra'.
  • Two in tests/utilities/test_stacklevel.py::StacklevelAttributionTests, through Probe(Info) at :83: __init__() missing 3 required positional arguments: '__finalised__', '__additional__', and '__excluded__'.
    • test_error_log_blames_the_same_line_from_every_depth
    • test_error_log_is_attributed_to_neither_pcapkit_nor_logging

I measured both signatures on 3.9 and 3.10.

Expected behavior
Read only a class's own annotations, cls_.__dict__.get('__annotations__', {}). The same pre-3.10 pitfall may affect four writes to cls.__annotations__[...], which would write into a base's dict: pcapkit/protocols/internet/ipv4.py:74, :150, :345 and pcapkit/protocols/internet/ipv6.py:76. I have not checked those.

Found while triaging main's KTLO legs at f20d0a600: Python 3.8 (KTLO) job 115570853800 (27 failed) and Python 3.9 (KTLO) job 115570853966 (9 failed). Since #1672, KTLO legs exit 0, so this shows only as a ::warning. Reproduced locally on CPython 3.8.20 and 3.9.25.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 14, 2026
  2. moved this to Pending in PyPCAPKiton Oct 14, 2026
  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 14, 2026
  4. moved this from Pending to WIP in PyPCAPKiton Oct 14, 2026
  5. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 14, 2026
  6. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions