Repository navigation
Conversation
Parse X and x tokens into integer microseconds before splitting normalized seconds and fractions. Avoid negative-fraction errors, scientific-notation failures and float precision loss. AI assistance: OpenAI Codex.
Merging this PR will not alter performance
|
Use exact stdlib epoch arithmetic instead of the existing Rust local_time helper. Preserve every regression and documentation assertion, including year1 and year9999, and verify full debug-native and pure suites on Python3.10 and3.12. AI assistance: OpenAI Codex.
Wkhanex
left a comment
There was a problem hiding this comment.
I checked d0b04f3 in pure-Python mode on Python 3.12 using integer microseconds as the independent oracle. For 2,000 seeded signed offsets around the epoch, both X decimal-second strings and x millisecond strings matched datetime(1970, 1, 1) + timedelta(...) exactly (4,000 comparisons). This included negative subsecond values and offsets far enough from the epoch that a float would lose low-order digits. The last microsecond of year 9999 and the start of year 1 also remained exact. The from-format module passed 87 tests. This checks the formatter path only; I have not run the whole suite or native backend.
Review and local validation prepared with OpenAI Codex assistance.
Pull Request Check List
Fix
from_format('0.000001', 'X')loses the microsecond;from_format('0.000012', 'X')raisesValueError; andfrom_format('-0.1', 'X')returns.100000rather than.900000in the preceding second. Negativexmillisecond values are likewise incorrect. Float conversion also loses precision at large timestamps and can round the final valid microsecond beyond year 9999.Parse the existing X/x grammars into exact integer microseconds and obtain calendar fields with stdlib epoch-plus-timedelta arithmetic. Timezone attachment remains unchanged. Add 26 regressions/controls and timestamp documentation examples.
Validation and CI correction
The first submitted head passed full local pure-Python and release-native checks, but hosted native testing failed on the retained year-1 case. CI uses Rust's debug profile; the existing native
local_timehelper panics with unsigned overflow there, while release arithmetic wraps. This exposed a gap in the initial local build-profile coverage.The corrective commit avoids that helper using exact stdlib integer date arithmetic. Every test and documentation byte is retained, including year 1/year 9999. No Rust code, overflow settings, dependencies, skips or check configuration were changed.
Revised validation on Linux:
The unchanged skips cover Windows-only behavior and upstream timezone-transition limits. Existing INFO-level docs anchor notices and Cargo packaging diagnostics remain. Replacement hosted CI and other platforms are not claimed passed until verified. Prepared and tested with AI assistance (OpenAI Codex); no human review is claimed.