Skip to content

fix: use match.groupdict().get() to prevent IndexError on malformed format#1327

Open
fazalpsinfo-cmyk wants to merge 2 commits into
arrow-py:masterfrom
fazalpsinfo-cmyk:master
Open

fix: use match.groupdict().get() to prevent IndexError on malformed format#1327
fazalpsinfo-cmyk wants to merge 2 commits into
arrow-py:masterfrom
fazalpsinfo-cmyk:master

Conversation

@fazalpsinfo-cmyk

Copy link
Copy Markdown

Fix: Use match.groupdict().get() to prevent IndexError on malformed format

Issue: #1191match.group(token) raises IndexError: no such group when a malformed format string is used.

Fix: Changed match.group(token) to match.groupdict().get(token) which returns None for non-existent groups. The existing ParserMatchError check on line 432 already handles the None case gracefully.

Change: 1 line in arrow/parser.py.


If you found this fix useful, consider supporting the work at https://buymeacoffee.com/muhamedfazalps

…ormat

match.group(token) raises IndexError when the token doesn't correspond
to a regex named group. Using match.groupdict().get(token) returns None
instead, which is already handled by the existing ParserMatchError check.

Fixes arrow-py#1191
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2224255) to head (60518ff).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1327   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2315      2315           
  Branches       358       358           
=========================================
  Hits          2315      2315           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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