Skip to content
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

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Mar 7, 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).

…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 pganssle added 3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes and removed awaiting merge labels Mar 8, 2025
@ZeroIntensity ZeroIntensity added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes and removed 3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Mar 8, 2025
Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Paul Ganssle <[email protected]>
@mgorny
Copy link
Contributor Author

mgorny commented Mar 8, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants