diff --git a/picard/util/__init__.py b/picard/util/__init__.py index 59968c7beb..453f647bff 100644 --- a/picard/util/__init__.py +++ b/picard/util/__init__.py @@ -946,7 +946,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 diff --git a/test/test_utils.py b/test/test_utils.py index d131d9689b..2b5068282c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -172,6 +172,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)