Repository navigation
fix(pcapng): keep out-of-range if_tzone as captured and catch every fromtimestamp failure (#1340) - #1429
Merged
Conversation
…romtimestamp failure (#1340) - An if_tzone of 24 hours or more, which no datetime.timezone can hold, is kept as captured as a timedelta with a ProtocolWarning instead of raising ValueError; the interface's timestamps render in UTC, and the option rebuilds byte-exactly. - _read_timestamp now falls back to the epoch with its existing warning on OverflowError and OSError as well as ValueError, so an extreme if_tsoffset no longer escapes from datetime.fromtimestamp. New tests/protocols/misc/test_pcapng_tzone_tsoffset_range_1340_unit.py.
Owner
Author
|
Verdict: GOOD TO GO at
|
Contributor
|
Coverage: 89.45% (unit tier, Python 3.14,
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.
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort) — Makefile flags on the twopcapng.pyfiles; isort clean, no mypy/pylint finding on a changed line (5 pre-existing mypy errors)make testpasses, and a test case covers the change — legs below, not the full suiteAdded a changelog entry — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657
fix— corrects a defectorigin/mainif_tzone±86400, −2³¹, 2³¹−1ValueErrorfromdatetime.timezonetimedelta+ProtocolWarning; packets render in UTC; IDB rebuilds byte-exactif_tzone±86399timezoneif_tsoffset±2⁶², −2⁶³OSErrorinvalid timestampwarning, epoch-0 datetime, epochDecimalkeptif_tsoffset2⁶³−1OverflowErrorThis follows the existing
_read_timestampfallback and the "kept as captured" precedent (#1412, #1425). AProtocolErrorwould drop the whole IDB and could not round-trip.IF_TZoneOption.timezoneis widened totimezone | timedelta. Thetimedeltaonly appears for values that used to raise, so this is not marked breaking.The new
tests/protocols/misc/test_pcapng_tzone_tsoffset_range_1340_unit.pyhas 5 tests and 26 subtests, covering the min, max and just-out-of-range values plus the largest EPB timestamp on top of a ±2⁶³ offset. Without the fix it fails 12 (6ValueError, 4OSError, 2OverflowError). Legs: eachtests/protocols/miscmodule run separately, all passed;run_unittest_leg.py protocols --exclude protocols/internet1081 OK;tests/project404 passed.Closes #1340