Repository navigation
fix(pcapng): default a made EPB/PB/ISB timestamp without an AttributeError (#2362) - #2382
Conversation
|
Review: GOOD TO GO at Two corrections to my own commit message/PR body: "ISB via isb_starttime/isb_endtime" understates it — the ISB block's own Timestamp field crashes too, not just its options. And "the same lookup already made two lines later for the offset" is wrong — the pre-existing lookup reused for the scale is Two mutation survivors found (interface_id hard-coded to 0, and the time_ns-vs-float clock branch unpinned) — fix dispatched, plus the docstring-tense nit. Issue label flipped pending→wip. |
|
Coverage: 91.58% (unit tier, Python 3.15,
Per-file detail: the |
bcdc8f8 to
83d7234
Compare
|
Amended All findings now addressed. |
…Error (#2362) Problem: _make_timestamp picked a defaulted timestamp's clock by reading self.nanosecond, which resolves its interface through the parsed data model. A block being made has no such model yet, so make() without an explicit timestamp raised AttributeError: '_info' for every block that carries one -- the Enhanced Packet Block, the obsolete Packet Block, and the Interface Statistics Block, through its own Timestamp field as well as its isb_starttime/isb_endtime options. Fix: read the resolution from _get_resolution(interface_id) instead -- the lookup the method already made for the scale; the offset keeps its own _get_offset(interface_id) -- no new fallback, matching every other make-path lookup in this file. Test: tests/protocols/misc/test_pcapng_epb_pb_default_timestamp_2362_unit.py covers all three block kinds defaulting their timestamp to the current time, scaling to the interface's declared resolution and offset, reading the correct interface rather than interface 0 in a multi-interface section, reading the nanosecond clock rather than the float one when resolution calls for it, and round-tripping. Each case raises AttributeError on the parent commit.
83d7234 to
384a4f6
Compare
|
Amended All findings across both rounds now addressed. |
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix — bug fixDescription
Closes #2362.
_make_timestamppicked a defaulted timestamp's clock by readingself.nanosecond, which resolves its interface through the parsed data model. A block being made has no such model yet, somake()without an explicittimestampraisedAttributeError: '_info'for every block that carries one — the Enhanced Packet Block, the obsolete Packet Block, and the Interface Statistics Block, through its own Timestamp field as well as itsisb_starttime/isb_endtimeoptions._get_resolution(interface_id)instead — the lookup the method already made for the scale; the offset keeps its own_get_offset(interface_id)— no new fallback, matching every other make-path lookup in this file.tests/protocols/misc/test_pcapng_epb_pb_default_timestamp_2362_unit.pycovers all three block kinds defaulting their timestamp to the current time, scaling to the interface's declared resolution and offset, reading the correct interface rather than interface 0 in a multi-interface section, reading the nanosecond clock rather than the float one when resolution calls for it, and round-tripping. Each case raisesAttributeErroron the parent commit.Note:
make()of EPB/PB/SPB withctx=Nonestill raises a separate, pre-existingUnsupportedCallon_get_linktype— a different symptom in a different method, out of scope here; worth its own issue if not already tracked.