Repository navigation
fix(utilities): encode pre-1970 datetimes on GraalPy without its lost second (#2134) - #2136
Conversation
|
GOOD TO GO at
|
|
Coverage: 91.55% (unit tier, Python 3.15,
Per-file detail: the |
|
Ready to merge at
This closes #2134. The GraalPy experimental leg on |
|
why not |
|
No good reason. Every sibling page under I'll switch both |
… second (#2134) GraalPy's aware datetime.timestamp() counts whole seconds toward zero, so an instant before 1970 with a fraction encoded a second late in the MH replay protection option, the PCAP frame header and PCAP-NG blocks. - pcapkit.utilities.timestamp.totimestamp computes (dt - epoch).total_seconds() for an aware dt on GraalPy, and is dt.timestamp() everywhere else; the three encoders call it. The module's rst page renders both functions with autofunction, their docstrings carrying the prose and versionadded notes. - test_fromtimestamp_windows_range_2099_unit: GraalPy's timezone.fromutc raises ValueError, not OverflowError, for a result before year 1; the test accepts it there. - test_io_buffer_save_tempfile_2098_unit: wait for the reader's finaliser with collect_until, since GraalPy can run it after gc.collect() returns; the helper moves from test_extraction_ownership to tests/_support. - New tests/utilities/test_totimestamp_graalpy_2134_unit emulates GraalPy's timestamp() on any interpreter. Target tests pass on CPython 3.14 and GraalPy 25.4.4; tier guard passes.
3cef9a0 to
d5c0e7c
Compare
|
GOOD TO GO at
The ready note follows once CI finishes on this head. |
|
Ready to merge at
This closes #2134. |
|
Debating if we should rename the timestamp module as time or datetime to match the house convention of reusing stdlib names. |
|
Recommendation: rename it to
Labelled |
|
Take datetime then |
|
Taking |
Per the owner's ruling on #2136, pcapkit.utilities.timestamp becomes pcapkit.utilities.datetime, reusing the stdlib name as utilities.logging and utilities.warnings do. The old path was added by #2111 and is in no release, so it is deleted with no re-export. - move the module and its docs page, and update the toctree - update the MH, PCAP frame and PCAP-NG importers and the tests - test that the new module exposes fromtimestamp and totimestamp, imports the stdlib datetime, and that the old path no longer imports
|
GOOD TO GO at
|
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #2134. Each failure was root-caused on real GraalPy 25.4.4, the build CI uses:
test_collection_removes_the_temporary_file_of_an_unclosed_reader: the test assumed CPython's immediate finalisation. GraalPy'sgc.collect()runs only the weakref callbacks already queued, so the finaliser can land after it returns. The test now uses the test: sort the remaining GraalPy-only failures into defects and gates #1963collect_until/FINALISER_GRACEhelpers, moved intotests/_support.py.test_errors_are_cpythons: a GraalPy difference. Itstimezone.fromutcraisesValueError: year 0 is out of rangewhere CPython raisesOverflowError. The test now expects GraalPy's class on GraalPy; the library is unchanged.test_mesg_id_before_1970: a real wrong-bytes defect on GraalPy.datetime.timestamp()truncates the whole seconds toward zero. So a pre-1970 instant with a fraction comes out one second late: 1969-12-31 23:59:59.5 UTC gives0.5, not-0.5.pcapkit.utilities.datetime.totimestamp(dt)uses(dt - epoch).total_seconds()on GraalPy for an awaredt, anddt.timestamp()everywhere else, so CPython output is byte-identical.pcapkit/utilities/timestamp.py(added in fix(protocols): convert capture timestamps without the platform's fromtimestamp limits (#2099) #2111, never in a tag) is renamedpcapkit/utilities/datetime.py, matching the house habit of reusing stdlib names. No re-export at the old path;tests/utilities/test_utilities_datetime_module_unit.pypins that.Tests:
tests/utilities/test_totimestamp_graalpy_2134_unit.pyreproduces GraalPy'stimestamp()on any interpreter. With the call sites reverted, it fails 5 cases on CPython.tests/project+tests/utilitiesgive 2038 passed, and the tier guard gives 133 passed.The GraalPy citations point at graalpython's source at
graal-25.4.4; no upstream issue has been filed yet.