Repository navigation
fix(protocol): raw items in a make() list build a packet; str enum names resolve per argument - #1352
Conversation
|
Cross-review verdict on 1. The broad Fix: when the re-parse fails and raw items are present, raise a 2. Not blocking. Held up:
|
…mes resolve per argument - #1312: unpack() read the schema make() returned, so raw bytes items (options, parameters, chunks, MH data) reached read() and crashed with AttributeError. When make() was given raw or Schema items, a made schema holding raw bytes where parsing its packed octets yields a schema is replaced by the parsed one; octets that do not parse raise ProtocolError. A bare MH() now constructs. - #1308: _make_index_namespace() locates the _make_index call in the caller's source and resolves the name against that call's own argument, so two arguments holding the same member name no longer raise "ambiguous member name". The all-arguments check remains the fallback when the source is unavailable or the first argument is not a parameter. test_make_index_str_unit pinned the old ambiguous-name raise and is updated; new tests in tests/protocols/test_protocol_make_unit.py.
2a7ca1c to
f345fe8
Compare
|
Round-2 verdict on
One residual gap, stated in the PR body. A tuple-form option whose maker returns raw bytes would not set the flag. No such maker is known in-tree. |
|
Coverage: 89.31% (unit tier, Python 3.14,
Per-file detail: the |
…o longer raises the wrapped error (#1395) #1344 pads the IPv4 option area once at the end, so the schema now accepts octets read() then rejects (an option whose length runs past the area), and the reader's bare ProtocolError escaped the wrap #1352 put around the schema re-parse only. unpack() now wraps the read as well when the made header holds raw items, and the wrapped message carries the original one. The same escape is fixed for TCP, HOPOPT, IPv6-Opts, MH, SCTP and HIP. Closes #1394
protocol.py; they report nothing new in the changed linesmake testpasses, and a test case covers the change — I ran only the two unittest legs,tests/projectand the touched modules (below)What is the purpose of your pull request?
fix— corrects a defectCloses #1308
Closes #1312
#1312.
unpack()reused the made schema, so rawbytesitems reachedread()and crashed withAttributeError.make()was given raw orSchemaitems, and the made schema still holds raw bytes where parsing yields a schema. The parsed header then replaces the made one.ProtocolErrorchained from the parse error. It catches onlyBaseErrorandstruct.error.mainthis crash hit 8 protocols: HIP, IPv4, TCP, HOPOPT, IPv6_Opts, MH (including a bareMH()), SCTP and IPv6_Route.#1308.
_make_index_namespacelocates the_make_indexcall withastand resolves against that call's first argument. All 111 call sites pass a plain name. 12 of them, inhip.py, pass loop variables rather than parameters (group,suite,cipher,mode,reg,tf). When the first argument is not a parameter, or the source is unavailable, it falls back tomain's all-arguments check. Sox = b; self._make_index(x)behaves as onmain.Behaviour change:
test_make_index_str_unitpinned the ambiguous-name raise, so I updated it.Cost: best of 3, 10,000 constructions each:
main(4849d16e4)TCP()IPv4(protocol=253)The host load average was about 6 during the runs.
Evidence:
test_protocol_make_unit.pygives 25 failed, 4 passed againstmain'sprotocol.py, and 12 passed with the fix.protocols/internet529 tests, 0 failures, 0 errors; the rest ofprotocols918 tests, 0 failures, 0 errors.tests/project: 389 passed, 1 skipped.infois identical tomainon all 23 fixtures.