You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parse_date raises IndexError for explicit fixed-width formats without separators #1515
format_date emits dates with adjacent numeric fields for explicit patterns such as ddMMyyyy and yyyyMMdd. parse_date raises IndexError when it receives the same output and pattern.
ddMMyyyy 01042004 IndexError list index out of range
yyyyMMdd 20040401 IndexError list index out of range
dd.MM.yyyy 01.04.2004 2004-04-01
2004-04-01
Expected Results
Both explicit fixed-width patterns should parse their corresponding strings as date(2004, 4, 1), matching the separated pattern and the documented use of an explicit date format.
Reproducibility
Reproduced with the official Babel 2.19.0 PyPI wheel and unmodified babel/dates.py from master at 394f91a41e5e9582e4a61502be8269fe6bebb676. The source checkout used the official wheel's locale data. Python 3.10.14 on macOS 15 arm64.
Additional Information
parse_date currently captures each consecutive digit run with re.findall(r'(\d+)', string), which yields a single entry for these inputs. It then indexes that list for the year, month, and day. The existing basic ISO path already accepts 20040401 in the default mode, as the final control demonstrates. Current parser
OpenAI Codex assisted with reproduction and drafting.
Activity