FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` by mgorny · Pull Request #130962 · python/cpython · GitHub

Repository navigation

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

Merged
vstinner merged 5 commits into
python:mainfrom
mgorny:py-fromisoformat-130959
Mar 11, 2025
Merged

vstinner merged 5 commits into
python:mainfrom
mgorny:py-fromisoformat-130959

Conversation

mgorny commented Mar 7, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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).

…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`).
pganssle added 3.12 only security fixes 3.13 only security fixes 3.14 bugs and security fixes and removed awaiting merge labels Mar 8, 2025
ZeroIntensity added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes and removed 3.12 only security fixes 3.13 only security fixes 3.14 bugs and security fixes labels Mar 8, 2025
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

mgorny commented Mar 8, 2025

Copy link
Copy Markdown
Contributor Author

Thanks!

mattip pushed a commit to pypy/pypy that referenced this pull request Mar 8, 2025
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

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

vstinner merged commit 33494b4 into python:main Mar 11, 2025

Copy link
Copy Markdown

Thanks @mgorny for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @mgorny and @vstinner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 33494b4d0dafc34ff4f1c118b7b3b5d8de3dd0f4 3.13

Copy link
Copy Markdown

Sorry, @mgorny and @vstinner, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 33494b4d0dafc34ff4f1c118b7b3b5d8de3dd0f4 3.12

bedevere-app Bot commented Mar 11, 2025

Copy link
Copy Markdown

GH-131076 is a backport of this pull request to the 3.13 branch.

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

Co-authored-by: Michał Górny <mgorny@gentoo.org>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL