fix: don't invent a day under STRICT_PARSING#1347
Open
apoorva-01 wants to merge 1 commit into
Open
Conversation
A YMD locale left a spare token that got reused for both the missing month and day, so "10/2017" slipped through as 2017-10-10. Only reuse a leftover token once when parts are enforced.
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.
parse("10/2017", settings={"STRICT_PARSING": True})gives2017-10-10instead ofNone. Only for YMD locales likezh(enis already fine).What happens: "10/2017" leaves one spare token ("10") and the back-fill reuses it for both the missing month and day, so the date looks complete and the strict check never fires.
Fix: under
STRICT_PARSING/REQUIRE_PARTS, use each leftover token only once. Day stays unset, so it's rejected.Kept it scoped to the strict path so non-strict output doesn't change (
zhstill gives2017-10-10). Wider fix would stop the reuse everywhere and matchenat2017-10-02, but that shifts default behavior, so your call. Happy to widen it.Tests at the
parse()level, fail on master, pass here.Fixes #850