diff --git a/src/pendulum/parsing/__init__.py b/src/pendulum/parsing/__init__.py index 20ebed40..d88c089a 100644 --- a/src/pendulum/parsing/__init__.py +++ b/src/pendulum/parsing/__init__.py @@ -145,7 +145,7 @@ def _parse_common(text: str, **options: Any) -> datetime | date | time: month = 1 day = 1 - if not m: + if not m or not (m.group("date") or m.group("time")): raise ParserError("Invalid datetime string") if m.group("date"): diff --git a/tests/parsing/test_parsing.py b/tests/parsing/test_parsing.py index 0fa0e936..8151ce12 100644 --- a/tests/parsing/test_parsing.py +++ b/tests/parsing/test_parsing.py @@ -684,6 +684,11 @@ def test_invalid(): parse(text) +def test_parse_empty_string(): + with pytest.raises(ParserError): + parse("") + + def test_exif_edge_case(): text = "2016:12:26 15:45:28"