Skip to content

fix(corekit): BitField drops the bits its namespace does not name #1487

Closed

Description

@JarryShaw

Describe the bug
An unpacked BitField re-packs to different bytes when its namespace leaves bits unnamed.

Reproduction

from pcapkit.corekit.fields.strings import BitField
f = BitField(length=2, namespace={'a': (0, 1), 'c': (8, 4)})({})
f.pack(f.unpack(b'\xff\xff', {}), {}).hex()   # '80f0'

Expected behavior
'ffff': the unnamed bits come back as captured.

System information
Linux, CPython 3.14.7, main at 00d232890.

Additional context
pack starts from all zeros (pcapkit/corekit/fields/strings.py:311), and unpack keeps only the named subfields (:334). None of the 102 BitFields in the shipped schemas leaves a bit unnamed, so no protocol is affected today; the #1202 corekit slice pins that.

Found by the #1202 corekit round-trip slice.

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

    @JarryShaw
    OwnerAuthor

    Blocked until #1492 merges. #1492 adds the Gap row for this defect to tests/corekit/_roundtrip.py, and the fix must delete that row in the same PR.

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

    @JarryShaw
    OwnerAuthor

    Unblocked: #1492 merged (d9e12e82e). A worker is starting on this against current main; the fix PR deletes this defect's Gap row.

  5. 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 9, 2026
  6. moved this from Blocked to WIP in PyPCAPKiton Oct 9, 2026
  7. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 9, 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