Skip to content

Commit

Permalink
PICARD-3008: Handle OverflowError in extract_year_from_date
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Dec 4, 2024
1 parent 24f24e7 commit a5a967c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion picard/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def extract_year_from_date(dt):
return int(dt.get('year'))
else:
return parse(dt).year
except (TypeError, ValueError):
except (OverflowError, TypeError, ValueError):
return None


Expand Down
1 change: 1 addition & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def test_string(self):
self.assertEqual(extract_year_from_date('2020-02-28'), 2020)
self.assertEqual(extract_year_from_date('2015.02'), 2015)
self.assertEqual(extract_year_from_date('2015; 2015'), None)
self.assertEqual(extract_year_from_date('20190303201903032019030320190303'), None)
# test for the format as supported by ID3 (https://id3.org/id3v2.4.0-structure): yyyy-MM-ddTHH:mm:ss
self.assertEqual(extract_year_from_date('2020-07-21T13:00:00'), 2020)

Expand Down

0 comments on commit a5a967c

Please sign in to comment.