Skip to content

fix(corekit): a NumberField whose bit_length is narrower than its octets drops the high bits #1488

Closed

Description

@JarryShaw

Describe the bug
An integer field with bit_length smaller than its width does not round-trip.

Reproduction

from pcapkit.corekit.fields.numbers import UInt16Field
f = UInt16Field(bit_length=12)({})
f.pack(f.unpack(b'\xff\xff', {}), {}).hex()   # '0fff'

Expected behavior
'ffff'. EnumField(length=1, bit_length=3) behaves the same way.

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

Additional context
Both pack and unpack mask with _bit_mask (pcapkit/corekit/fields/numbers.py:318, :322). The only shipped use is vlan.TCI (pcapkit/protocols/schema/link/vlan.py:47-51), which no protocol parses with.

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. moved this to Pending in PyPCAPKiton Oct 9, 2026
  3. 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.

  4. 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
  5. moved this from Pending to Blocked in PyPCAPKiton Oct 9, 2026
  6. 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.

  7. 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
  8. 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