From a5a967cdf813f4f832296131ef53275394ede029 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 2 Dec 2024 17:21:56 +0100 Subject: [PATCH] PICARD-3008: Handle OverflowError in extract_year_from_date --- picard/util/__init__.py | 2 +- test/test_utils.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/picard/util/__init__.py b/picard/util/__init__.py index 14b8a8cc33..d6882a70bf 100644 --- a/picard/util/__init__.py +++ b/picard/util/__init__.py @@ -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 diff --git a/test/test_utils.py b/test/test_utils.py index a21fa2c7fa..d6d998bb94 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -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)