Fix #966: More robust importer against malformed dates

environments/review-front-340-9n9j9v/deployments/3368
Eliot Berriot 2019-11-14 15:47:18 +01:00
rodzic 4e8278fbd8
commit 4dcdc93958
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6B501DFD73514E14
3 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -556,7 +556,7 @@ class PermissiveDateField(serializers.CharField):
try:
parsed = pendulum.parse(str(value))
return datetime.date(parsed.year, parsed.month, parsed.day)
except pendulum.exceptions.ParserError:
except (pendulum.exceptions.ParserError, ValueError):
pass
return None

Wyświetl plik

@ -239,6 +239,7 @@ def test_can_get_metadata_from_flac_file_not_crash_if_empty():
("2017-12-31", datetime.date(2017, 12, 31)),
("2017-14-01 01:32", datetime.date(2017, 1, 14)), # deezer format
("2017-02", datetime.date(2017, 1, 1)), # weird format that exists
("0000", None),
("nonsense", None),
],
)

Wyświetl plik

@ -0,0 +1 @@
More robust importer against malformed dates (#966)