Skip to content

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

Merged
vstinner merged 1 commit into
python:3.13from
vstinner:fromisoformat13
Mar 11, 2025
Merged

vstinner merged 1 commit into
python:3.13from
vstinner:fromisoformat13

Conversation

@vstinner

@vstinner vstinner commented Mar 11, 2025 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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

@mgorny mgorny left a comment

Copy link
Copy Markdown
Contributor

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
@vstinner
vstinner deleted the fromisoformat13 branch March 11, 2025 11:39
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Mar 11, 2025

Copy link
Copy Markdown

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

Labels

None yet

2 participants