-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-130959: Reject whitespace in fractions, in pure Python fromisoformat()
#130962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…isoformat()` Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`).
Misc/NEWS.d/next/Library/2025-03-07-19-24-27.gh-issue-130959.xO8vVS.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Library/2025-03-07-19-24-27.gh-issue-130959.xO8vVS.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]>
Thanks! |
Fix pure Python implementation of `fromisoformat()` to reject spaces in fractional part of time specifications. This matches the behavior of the C implementation in CPython, and prevents the method from parsing them incorrectly. This fixes Django's test suite by enabling a fallback to their own (working) parser. Backports: python/cpython#130962
Misc/NEWS.d/next/Library/2025-03-07-19-24-27.gh-issue-130959.xO8vVS.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, @mgorny and @vstinner, I could not cleanly backport this to
|
Sorry, @mgorny and @vstinner, I could not cleanly backport this to
|
GH-131076 is a backport of this pull request to the 3.13 branch. |
…isoformat()` (python#130962) Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`). Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]> (cherry picked from commit 33494b4)
…misoformat()` (#130962) (#131076) gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962) Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`). Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]> (cherry picked from commit 33494b4) Co-authored-by: Michał Górny <[email protected]>
…n `fromisoformat()` (pythonGH-130962) (pythonGH-131076) pythongh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (pythonGH-130962) Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`). Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]> (cherry picked from commit 33494b4) (cherry picked from commit 27fd328) Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Michał Górny <[email protected]>
…mat()` (GH-130962) (GH-131076) (#131086) Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`). (cherry picked from commit 33494b4) (cherry picked from commit 27fd328) Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Michał Górny <[email protected]>
…isoformat()` (python#130962) * pythongh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` Fix the pure Python implementation of `fromisoformat()` to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g. `.400 ` would be misinterpreted as `.04`). * Add the news entry * Use a different example to fix Sphinx lint * Apply suggestions from code review Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]> * Try fixing `:func:` ref. --------- Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Paul Ganssle <[email protected]>
Fix the pure Python implementation of
fromisoformat()
to reject any non-digit characters, including whitespace, in the fractional part of time specification. This makes the behavior consistent with the C implementation, and prevents incorrect parsing of these fractions (e.g..400
would be misinterpreted as.04
).fromisoformat()
handles times with trailing spaces inconsistently with the C extension #130959