Repository navigation
refactor(protocols): one home per duplicated RFC-fixed constant (#1739) - #1752
Merged
Merged
Conversation
Ruling 7 on #1726: an RFC- or format-fixed constant spelled out in more than one module is defined once, in the module that owns the protocol (or its schema or const module), and is never configurable. - IP/IPv4/IPv6/AH/TCP: IPV6_HEADER_LEN and IPV6_NEXT_HEADER_OFFSET live in protocols.internet.ipv6; IPV4_HEADER_LEN, AH_HEADER_LEN, TCP_MIN_HEADER_LEN, TCP_DATA_OFFSET_OCTET and IP_MAX_LENGTH in their schema modules, which spelled them too and cannot import the protocol modules; the toolkit, reassembly and schema copies are gone. - PCAP: GLOBAL_HEADER_LEN, MAGIC_NUMBER, RESOLUTION, RESOLUTION_PLACES in schema.misc.pcap.header and RECORD_HEADER_LEN in schema.misc.pcap .frame, read by the protocols and the pcap/pypcapfile/scapy engines. - PCAP-NG: BYTE_ORDER_MAGIC, BLOCK_MINIMUM, GENERIC_BLOCK_MINIMUM and DEFAULT_RESOLUTION live in schema.misc.pcapng; the engine tables are removed, and every block length derives from the two minimum tables. - No old home re-exports a name; none shipped in 1.4.x, so no versionremoved. Each new home has versionadded 1.5.0 and autodata. The guard sweeps protocols, foundation, toolkit and dumpkit for every integer literal of a homed value, wherever it sits -- operand, default, tuple, table, conditional or assignment at any level -- skipping only the homes' own definitions, and allowlists each non-copy with a reason. A reassembly test pins IP_MAX_LENGTH as a strict bound at its edge: a Total Length 0 datagram of exactly 65,535 octets does not grow the buffer, so a declared final fragment past it still never completes. Closes #1739
Owner
Author
|
Verdict: GOOD TO GO at
|
Contributor
|
Coverage: 89.59% (unit tier, Python 3.15,
Per-file detail: the |
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 change. Narrow runs only, listed below.Added 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
Closes #1739, which carries ruling 7 from #1726. Every RFC- or format-fixed constant that was spelled out in more than one module now has one home. That home is the module that owns the protocol, or its schema module, and every other place reads the constant from there. None of them is configurable.
Homes:
IP_MAX_LENGTH;Each home carries
versionadded:: 1.5.0and anautodataentry.No re-exports (refactor(corekit)!: move the byte-order field helpers into corekit (#1711) #1715, docs: #719-style prose sweep after the #1090–#1102 defect wave #1103): the old spellings are deleted. None of them shipped in 1.4.x, so they get no
versionremoved.Guard,
tests/project/test_rfc_constants_one_home_1739_unit.py: sweepsprotocols,foundation,toolkitanddumpkitfor every integer literal with a homed value, wherever it appears. Only the homes' own definitions are skipped. Every hit that is not a copy is allowlisted with a reason: 490 hits, 0 offenders.Edge test,
tests/foundation/reassembly/test_ip_max_length_edge_1739_unit.py: pinsIP_MAX_LENGTHas a strict bound.Tests, narrow runs on Python 3.14:
*_1739_unit.pyfiles plustest_unit_tests_queue.py: 69 passed, 675 subtests;tests/foundation/reassembly: 134 passed.Out of scope: the dpkt engine's loopback address-family keys repeat
Loopback.__proto__. Those numbers are set by the operating systems, not by an RFC, so they are not covered by #1739.