Repository navigation
fix(protocols): drop the warnings of a trial parse that is kept as Raw (#2308) - #2339
Conversation
#2308) Problem: a held trial parse in _parse_next_layer that raised had its warnings replayed by hold_warnings.__exit__ whatever discard said, and beholder then kept the layer as Raw, so an Ethernet frame cut inside its IPv4 header warned "packet length < 0" for a layer it does not have. Fix: hold_warnings honours discard on an Exception exit too; beholder marks its call in a context variable, and _parse_next_layer discards a raising trial's warnings under it. Outside beholder the error reaches the caller and the warnings are still reported. The Raw's error names the cut. Test: tests/protocols/test_trial_parse_raises_2308_unit.py; the #2236 test pins the cap_len argument directly and asserts the Raw's error; the #1580 tests that pinned the leak are retargeted to kept layers.
|
Review: GOOD TO GO at
|
|
Coverage: 91.56% (unit tier, Python 3.15,
Per-file detail: the |
|
Should we promote |
|
Recommendation: keep
|
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix — bug fixDescription
Closes #2308, per the ruling (take the recommendation).
hold_warnings.__exit__replayed held warnings on anyExceptionexit and ignoreddiscard. So a short trial parse in_parse_next_layerthat raised reported its warnings beforebeholderreplaced the layer withRaw.hold_warningshonoursdiscardon anExceptionexit too.beholdersets a_beholdingcontext variable, and a trial that raises discards its warnings only while abeholderwill replace the layer. With nobeholderon the stack, the error and its warnings still reach the caller.test_trial_parse_raises_2308_unit.pycovers the repro on both the warnings and the logger channels, theerrorfilter, a cut Hop-by-Hop header, and two controls (a kept Shim6 header still warns, and nobeholderstill warns). The docs(logging,pcap): per-frame logging note and Frame.read suite claim are false #2236 and fix(protocols): a trial next-layer parse that is replaced by Raw still emits its SchemaWarnings #1580 tests that pinned the leak are updated.origin/main, 5 failed. On the head, 23 passed.Raw, its warnings still show. That is pinned intest_layer_that_cannot_be_replaced_holds_nothing.