Skip to content

fix(foundation): _check_code(number=True) takes a bool, so register_tcp(True) adds port 1 #2269

Closed

Description

@JarryShaw

Describe the bug
_check_code lets any non-enum int through when number=True, and bool is an int subclass. So register_tcp, register_udp and register_sctp store True as key 1.

Reproduction (registries snapshotted and restored)

register_tcp(True, Raw)    # no error
TCP.__proto__.get(1)       # <class 'Raw'>, likewise UDP and SCTP

Expected behavior
RegistryError: code must be an int or a member of AppType, not True, registry unchanged. Suggested fix: reject isinstance(code, bool) before the number branch in _check_code. This is separate from #2268, where the mapping form skips _check_code altogether.

System information
Linux, CPython 3.14.9, pcapkit 1.5.0b14, checkout main 9d504ead5.

Activity

  1. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
  2. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    on Oct 26, 2026
  3. moved this to Pending in PyPCAPKiton Oct 26, 2026
  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 26, 2026
  5. moved this from Pending to WIP in PyPCAPKiton Oct 26, 2026
  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 27, 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

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions