8000 [3.13] gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962) by vstinner · Pull Request #131076 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] gh-130959: Reject whitespace in fractions, in pure Python fromisoformat() (#130962) #131076

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

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

vstinner
Copy link
Member
@vstinner vstinner commented Mar 11, 2025

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 zintensitydev@gmail.com
Co-authored-by: Paul Ganssle 1377457+pganssle@users.noreply.github.com
(cherry picked from commit 33494b4)

…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 <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
(cherry picked from commit 33494b4)
@vstinner
Copy link
Member Author

@mgorny: Would you mind to double check this backport to 3.13? I had to fix merge conflicts.

Copy link
Contributor
@mgorny mgorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see anything obviously wrong, and the tests passed. Thanks!

@vstinner vstinner merged commit 27fd328 into python:3.13 Mar 11, 2025
39 checks passed
@vstinner vstinner deleted the fromisoformat13 branch March 11, 2025 11:39
@miss-islington-app
Copy link

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-app
Copy link
bedevere-app bot commented Mar 11, 2025

GH-131086 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 11, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 11, 2025
…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 <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
(cherry picked from commit 33494b4)
(cherry picked from commit 27fd328)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Michał Górny <mgorny@gentoo.org>
vstinner added a commit that referenced this pull request Mar 11, 2025
…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 <vstinner@python.org>
Co-authored-by: Michał Górny <mgorny@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
48B4 Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0