Repository navigation
refactor(corekit): add pad_length and PaddingField(align=, after=) - #2624
Merged
Merged
Conversation
- strings.pad_length(length, align) returns -length % align; an align that is not a positive int raises IntError or FieldValueError. - PaddingField takes align and after (a field name or a callable giving the padded length) as an alternative to length; length callers are unchanged. - PCAP-NG schema: option, record and packet-data padding use align=; the option-area lengths, _spb_data_length and the journal check call pad_length. - SCTP schema: padding_length, nested_length and whole_chunks_length call pad_length; padding_length keeps its clamps, so it stays a callback. - HIP schema: parameter_total_len pads 4 + Length with pad_length. - Left for a later #2614 group: the protocol-class padding arithmetic in misc/pcapng.py, internet/hip.py and transport/sctp.py, and in foundation/engines/pcapng.py. - Tests: test_fields_pad_length_2614_unit; samples rebuild byte-identically.
Owner
Author
|
GOOD TO GO at
|
JarryShaw
added a commit
that referenced
this pull request
Nov 2, 2026
… kinds into 1.6.0 (#2449) - Added: pad_length and PaddingField's align/after form (#2624), and pcapkit.utilities.contextvars (#2623); the old private names get no entry, as for the other private API. - Changed: the weekly Issue and PR Kinds workflow, beside the milestone workflow's entry (#2626). - The conventions entry records where a context variable lives (#2623), and the role-kind citation rule with its test (#2626). - No entry for #2626's heading and Mermaid fixes, #2564 or fa9af52. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
1 of 5 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.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor— changes neither behaviour nor performanceDescription of your pull request and other information
Adds
pcapkit.corekit.fields.strings.pad_length(length, align)(-length % align) besidePaddingField, as the owner chose on #2614 (1a), and aPaddingField(align=…, after=…)form that states what the padding aligns. The PCAP-NG, SCTP and HIP schemas adopt it in place of the alignment arithmetic they spelled five different ways. ExistingPaddingField(length=…)callers are unchanged. The protocol-class padding arithmetic is left for a later #2614 group.Behaviour is unchanged. Every converted expression matches the old one over exhaustive length ranges. All 23 sample captures regenerate identically, and every one of their 6,900 layers parses and rebuilds byte-for-byte. A Sonnet cross-review returned GOOD TO GO. The two padding mutants it found surviving now have tests that kill them.
Part of #2614