Repository navigation
fix(corekit): keep a BitField's unnamed bits as captured (#1487) - #1495
Merged
Merged
Conversation
Owner
Author
|
Verdict: GOOD TO GO at
Non-blocking:
|
Contributor
|
Coverage: 89.65% (unit tier, Python 3.14,
Per-file detail: the |
BitField.post_process read only the named subfields and pre_process packed from all zeros, so a bit outside every subfield was cleared on rebuild. post_process now records those bits under an `__unnamed__` key, present only when one is set, and pre_process seeds the buffer from it, masked so it can never override a named subfield. A value built without the key packs them as zeros, as before. Deletes the #1487 Gap row from the field round-trip table. Closes #1487
JarryShaw
force-pushed
the
fix/1487-bitfield-unnamed-bits
branch
from
October 9, 2026 20:14
be50fbd to
910c898
Compare
Owner
Author
2 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
BitFieldcleared every bit its namespace leaves unnamed on rebuild.post_processnow records those bits under an__unnamed__key, as an int over the whole field with the named bits cleared, andpre_processseeds its buffer from it (pcapkit/corekit/fields/strings.py:277,:301,:329,:363).Why a key in the value: it is how #1380 (
__remainder__) and #1465 (__short_read__) keep what the capture held, and an ordinary key rides throughSchema.to_dict/from_dictwith no extra plumbing. As there, the key is absent when there is nothing to keep (all unnamed bits zero), so a user-built value packs them as zeros as before, and the record is masked so it can never override a named subfield.Eight shipped
BitFields leave bits unnamed, but all eight areForwardMatchFieldlook-ahead peeks, which never pack (e.g.schema/transport/tcp.py:792,schema/internet/ipv4.py:598), so no protocol output changes:repr(frame.info.to_dict())hashes over all 23examples/capturesfiles are identical onmainand here.Tests: new
tests/corekit/test_bitfield_unnamed_bits_1487_unit.py(12 failed onmain'sstrings.py, 9 pass here); the #1487Gaprow is deleted.tests/corekit477 passed,test_capture_roundtrip_runtime.py4 passed,tests/project419 passed / 1 skipped,test_docstring_contract.py7 passed.pylint/mypy/isortonstrings.pyshow no new findings; themaketargets were not run.Closes #1487