-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
datetime.datetime.isoformat parses input incorrectly #115225
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
Comments
Fractional hours and minutes should not be supported. We should change the The reason why they are not supported is that we decided that a string like @xitop How did you discover this? Were you using something that actually generates a string like that, or was this an attempt to find bugs? I'm curious to know if my reasoning about no one really using these features is correct. |
Pure chance. I was working on a software processing time intervals with a parser accepting various formats. I read the |
Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark.
Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark.
Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark.
Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…thon#119339) Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…thon#119339) Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…thon#119339) Some time strings that contain fractional hours or minutes are permitted by ISO 8601, but such strings are very unlikely to be intentional. The current parser does not parse such strings correctly or raise an error. This change raises a ValueError when hours or minutes contain a decimal mark. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
The implementation causes odd behavior for the pure Python implementation
C for reference:
|
The PR was merged some time ago.
IMO, exception chaining is perfectly fine. The final exception is the same; we don't really need to hide the reason. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
Actual result is
12:50:00.500000
, but according to ISO 8601 the string represents12:50:30
(50 and half minutes, format "HHMM.mmm", because "a decimal fraction may be added
to the lowest order time element present")
if partial minutes are not supported by Python as stated in the docs, a
ValueError
should be raised.Affected are versions 3.10+.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: