Skip to content

fix(registry): re-registering a stored ModuleDescriptor warns and replaces it with the class #1364

Closed

Description

@JarryShaw

Describe the bug
ProtocolBase.register (pcapkit/protocols/protocol.py:770-772), the Internet / Link / Transport / Frame / PCAPNG overrides, and Extractor.register_dumper (pcapkit/foundation/extraction.py:421-425) resolve a ModuleDescriptor argument to its class before comparing it with the stored entry. When the argument is the stored descriptor itself, incumbent is not protocol is true, so it warns and the entry becomes the class (the deferred import is lost). The docstrings state that "an unresolved ModuleDescriptor incumbent counts as different from the class it names"; this issue is the narrower case where the same descriptor object is handed back.

To Reproduce
TCP.register(21, TCP.__proto__[21]) warns, and TCP.__proto__[21] is then a class. Extractor.register_dumper('json', *Extractor.__output__['json']) warns, and the entry's first item is then a class.

Expected behavior
Compare before resolving (if protocol is incumbent: return), or compare incumbent.klass is protocol without replacing a descriptor by an equal class. #739 flagged the descriptor/class meeting as a caveat. Separate fix from the presence-only guards of the sibling issue.

Found by the round-trip audit of pcapkit/foundation. Run /tmp/rtissues/foundation-repro.py from the repo root (it prints pcapkit.__file__ first).

Found by the foundation round-trip audit (#1202). The repro was re-checked by an independent verifier, and I re-ran it on main at c9676c563.

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 7, 2026
  2. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until #1352 merges, because both edit pcapkit/protocols/protocol.py, where Protocol.register resolves the descriptor (:764-770).

  3. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  4. moved this to Blocked in PyPCAPKiton Oct 7, 2026
  5. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1352 has merged, and no open PR now edits pcapkit/protocols/protocol.py. A worker is starting on it.

  6. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 7, 2026
  7. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Correction: still blocked, and I have not dispatched a worker. My last comment checked only protocol.py. The fix also has to change three files that open PRs are editing:

    Blocked until #1373, #1376 and #1378 merge. All three are already good-to-go.

  8. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 7, 2026
  9. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Still blocked, now on a different PR. #1373, #1376 and #1378 have merged. The PCAPNG registrar override in protocols/misc/pcapng.py is about to be edited by the PCAP-NG half of #1398. Blocked until #1398 merges.

  10. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Still blocked, now on a different PR. The fix also needs the PCAPNG registrar override in protocols/misc/pcapng.py, which the PCAP-NG follow-up worker for #1382–#1384, #1401, #1405 and #1406 is about to edit. Blocked until that PR merges.

  11. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 8, 2026
  12. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1412 merged (ec2ba13a4). A worker is on it now.

  13. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 8, 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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions