Repository navigation
Closed
Labels
refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)testPull requests that add or correct tests (test: subject prefix)Pull requests that add or correct tests (test: subject prefix)
Milestone
Description
Is your feature request related to a problem? Please describe.
These branches and names can never run or be read:
-
Header.read(pcap): theif _decl is None: raise FileError(...)branch is dead, because the schema'smagic_number_callbackraises first.Header(io.BytesIO(b'\x00\x01\x02\x03' + bytes(20)))raisesProtocolError: invalid magic number, so theRaises: FileErrorin the docstring is wrong too. -
_read_opt_qsinIPv4,HOPOPTandIPv6_Opts: the finalelse: raise ProtocolError(... unknown QS function ...)is dead. Since fix(ipv4): an unassigned Quick-Start function code fails the whole header #1322 and fix(ipv6-opts): an unassigned Quick-Start function code fails the whole header #1237 the schema sends an unassigned function toUnassignedOption; I parsed every function nibble from 0 to 15 and none reached it. -
_read_opt_calipso(HOPOPT,IPv6_Opts): both length guards are dead, becausecalipso_pad_lenalready raisesFieldValueError: HOPOPT: invalid CALIPSO option length: 7for anylen < 8 + cmpt_len * 4. The% 8 != 0clause is redundant even by itself. - Commented-out
raiselines sit next to thewarnthat replaced them:_make_opt_pad(HOPOPT,IPv6_Opts,MH),IPv4._read_opt_sec,HIP._read_param_hip_cipher, the HIP schema'spre_unpack,HTTP/2._read_http_none, PCAP-NG'sts_*properties and_get_*helpers, and the PCAP-NG schema's block-lengthpost_process. -
_read_opt_qs(HOPOPT,IPv6_Opts) repeats# pylint: disable=unused-argumenton itsdefline. -
examples/generators/dispatch.py:code_namenever reads_internet_enum, because no key inInternet.__proto__is a bareintany more. Thecode_namedocstring still says one is. -
tests/project/test_release_tags_the_run_sha_1634.py: the'--json assets --jq .assets[].name'arm ofFAKE_GHanswers a query nothing makes;util/release_upload.pyonly sendsASSETS_JQ. -
tests/project/test_sweeps_on_latest_only_1732.py:GATINGis defined and never read, andtest_pypy_worker_memory_2005does not import it either.
Describe the solution you'd like
Delete each one, changeHeader.read'sRaises:toProtocolError, and update the comments and docstrings that describe what was removed (code_name, theFAKE_GHnote).
Describe alternatives you've considered
Havingmagic_number_callbackraiseFileError, so that the documented exception becomes true. That changes the exception that every caller now gets for a bad file.
Additional context
Dead branches make the code look as if it handles cases it never sees, and coverage cannot reach them.
Related: #2300 rewords the magic-number message that Header.read actually raises; #2312 was split out of this list because it needs a ruling.
Metadata
Metadata
Assignees
Labels
refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)testPull requests that add or correct tests (test: subject prefix)Pull requests that add or correct tests (test: subject prefix)
Projects
- StatusShow more project fieldsDone
Activity
JarryShaw commentedon Oct 26, 2026
Blocked until the round-7 fix PRs for #2268–#2316 merge. This change spans the protocol modules those fixes edit, so it starts from the merged tree.
JarryShaw commentedon Oct 27, 2026
Fixing #2318 turned up a judgment call. Three existing tests reached what the issue calls dead code, but only by hand-fabricating a schema object and calling the private reader directly — bypassing
unpack()entirely, which no real parse can do:Headerwith a bad magic number, built viaobject.__new__instead of a real byte stream, to reach aFileErrorbranch;IPv4/IPv6cases with aQuickStartRequestOption/CALIPSOOptionschema hand-built to disagree with itself.My recommendation: these are genuinely dead on any real input, so the branches come out and the three tests move to the real path (e.g.
Header(io.BytesIO(bad_bytes))), which the PR already does. If you'd rather keep a guard reachable only by a fabricated object — for defence-in-depth against a hand-built schema passed in some other way — say so and I'll restore it with a test that builds it that way instead.JarryShaw commentedon Oct 27, 2026
take your recommendations
JarryShaw commentedon Oct 27, 2026
Ruling noted: taking the recommendation (remove the branches, move the three tests to the real path). Already implemented that way in the committed fix; proceeding to PR.
refactor: remove two unreachable branches, commented-out raises and u…
refactor: remove two unreachable branches, commented-out raises and u…
refactor: remove two unreachable branches, commented-out raises and u…
JarryShaw commentedon Oct 27, 2026
Closing note for the record: this issue's original "dead code" claim for
_read_opt_qs's unknown-QS-function arm was based on parse-only evidence (reachable only by calling the private reader directly). The fix in #2378 found that arm is actually reachable via the public construction path too — aQuickStartRequestOption/QuickStartReportOptionbuilt directly with an unassignedfunchits it regardless of parse dispatch — so it was kept rather than removed, unlike the other two guards this issue named (Header.read'sFileError,_read_opt_calipso's length guards), which are confirmed genuinely dead through both construction and parse routes.refactor: remove two unreachable branches, commented-out raises and u…
refactor: remove two unreachable branches, commented-out raises and u…