Repository navigation
fix(corekit): keep a NumberField's bits outside bit_length as captured (#1488) - #1497
Conversation
|
Verdict: NEEDS CHANGES at Required: a captured value must carry its capture conditions, and only a field with the same width and
What checked out:
Also needed: the |
|
Coverage: 89.65% (unit tier, Python 3.14,
Per-file detail: the |
687596c to
656dc4c
Compare
|
Verdict: GOOD TO GO at
Non-blocking:
|
656dc4c to
1c626ed
Compare
1c626ed to
8da3cbd
Compare
|
Verdict carried to
|
|
Verdict carried to
|
8da3cbd to
7771574
Compare
#1488) - NumberField.post_process: when the octets carry bits outside bit_length that pre_process would not write back (zeros, or a negative signed value's sign extension), return an int subclass recording them with the capturing field's length, bit_length, sign and byte order. pre_process writes them back only for a field matching all four; any other field, and any other value, is truncated to bit_length bits as before. - EnumField.post_process: carry that record on the pseudo-member, or on an unregistered copy of a registry member, which stays isinstance and equal. - Delete the Gap(1488) row; relax one assertIs pin to isinstance/equality for an octet whose spare bits are set.
7771574 to
db3b2ec
Compare
|
Verdict carried to |
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
bit_lengthsays only the low N bits of a field's octets are its value (vlan.TCI, which no protocol parses with). Unpack and pack both masked, so the other bits were lost.post_processstill returns the low N bits. If the other bits differ from whatpre_processwrites for that value (zeros, or sign extension for a negative signed value), it returns_CapturedInt, anintsubclass that records(outside, length, bit_length, signed, byteorder).pre_processwrites the bits back only when its own length, bit_length, sign and byte order all match the record. Any other field packs the value exactly aspack(int(v))would, e.g.UInt16Field()gives0fffandUInt8Field()givesff.EnumFieldputs the same record on the pseudo-member, or on an unregistered copy of a registry member (_unregistered_member). The copy is stillisinstanceand equal, but is no longer the identical object. OneassertIspin intest_fields_numbers_unassigned_enum.pyis relaxed to match.0x1fffgives0fff).Gap(1488)row is deleted.Ran (sequentially): new test,
tests/corekit,tests/protocols/link,tests/protocols/test_capture_roundtrip_runtime.py,tests/project,tests/test_docstring_contract.py, all green. The new test fails onmain'snumbers.py, and its scoping cases fail on the previous head687596c53.repr(frame.info.to_dict())hashes over all 23examples/capturesmatchmain.Closes #1488