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

Fix fuzzy parse dropping year before trailing ":" (#326) by IMGillusion · Pull Request #1566 · dateutil/dateutil · GitHub

Fix fuzzy parse dropping year before trailing ":" (#326) - #1566

Open
IMGillusion wants to merge 1 commit into
dateutil:masterfrom
IMGillusion:fix-326-trailing-colon-fuzzy-year
Open

IMGillusion wants to merge 1 commit into
dateutil:masterfrom
IMGillusion:fix-326-trailing-colon-fuzzy-year

Conversation

Copy link
Copy Markdown

Summary

With fuzzy=True, a 4-digit year immediately followed by : was dropped entirely, so parse("23. November 2016:", fuzzy=True) returned the default year (2026) instead of 2016.

Root cause: in _parse_numeric_token, the terminal-token branch (idx + 1 >= len_l or info.jump(...) — "year, month or day") never matched when the next token was :, so the number fell through to the fuzzy skip path and the year was lost.

Changes

  • Extend that branch to also treat a following : as terminal, keeping the year token.
  • When the following token is :, return before consuming it, so in fuzzy_with_tokens=True mode the colon is reported among the skipped tokens.

Tests

  • New regression test testFuzzyTrailingColonAfterYear covering the issue examples (23. November 2016:, 18 October 1874:), the default=datetime.min case, and skipped-token reporting.
  • Full test suite: identical failure set to unmodified master (only pre-existing environment-related tz failures); tests/test_parser.py fully passes.

In _parse_numeric_token, extend the terminal-token branch to treat a
':' following a number as terminal too, so 4-digit years such as
'2016:' are kept as year tokens instead of being dropped. When the
token is followed by ':', return before consuming it so fuzzy mode
reports the colon among the skipped tokens.

Fixes dateutil#326
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.

1 participant


Back | FazBrowse Home | New Git URL