#1191·arrow

IndexError in DateTimeParser.parse

Author: gabe-shermanCreated Oct 4, 2024Updated Jul 30, 2026
Labelsbug

The below code triggers a list index out of range error when provided a malformed input. This occurs in parse at line 335 in arrow/parser.py. It seems that when the fmt string is malformed this can lead to a matching error in the regex parsing later in the function.

from arrow.parser import DateTimeParser
import sys

buf = open(sys.argv[1], "rb").read().decode("utf-8")
parser = DateTimeParser()
parser.parse("foo", buf)

Version

1.3.0

POC File

https://github.com/FuturesLab/POC/blob/main/arrow-py/poc-01

How to trigger

python filename.py poc-01

Trace Report

Traceback (most recent call last):
  File "rep.py", line 6, in <module>
    parser.parse("foo", buf)
  File "anon/lib/python3.8/site-packages/arrow/parser.py", line 331, in parse
    value = match.group(token)
IndexError: no such group