Repository navigation
Reject a decimal fraction of the hour or minute in parse() - #1105
Open
kevincommits wants to merge 1 commit into
Open
kevincommits wants to merge 1 commit into
kevincommits wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
parse()reads a decimal fraction written after the minute as a fraction of a second, so it returns a wrong time instead of raising:Expected:
ParserError, the same as"2016-10-06T12:30.5"already raises with the Rust parser and asdatetime.time.fromisoformat("12:30.5")raises. In ISO 8601,12:30,5means 12:30:30, so 12:30:00.5 is wrong under any reading. WithPENDULUM_EXTENSIONS=0the pure Python ISO 8601 parser has the same problem for full datetimes:"2016-10-06T12,5"gives 12:00:00.5.The common format parser and the pure Python ISO 8601 parser now raise
ParserErrorwhen a fractional part follows the hour or minute instead of the seconds. Fractional seconds are unchanged. The Rust parser already rejects these strings, so it needs no change. This rejects the form rather than adding support for decimal hours and minutes, which the TODO in the Rust parser leaves open.The new test covers both parsers with extended and basic forms, a time-only string, and a datetime in the common format.
What I ran:
pytest -q testswith and withoutPENDULUM_EXTENSIONS=0(1877 passed;test_instance_with_aware_datetime_any_tzinfofails, and it also fails on master on my machine),mypy, andprek run --all-files.What I did not run: the clippy step of the Rust lint hook (clippy is not installed here; no Rust code changed), and the other Python versions and operating systems in the CI matrix.