diff --git a/poetry/packages/package.py b/poetry/packages/package.py index 680bf31f596..04854ec72af 100644 --- a/poetry/packages/package.py +++ b/poetry/packages/package.py @@ -163,6 +163,12 @@ def _get_author(self): # type: () -> dict m = AUTHOR_REGEX.match(normalize("NFC", self._authors[0])) + if m is None: + raise ValueError( + "Invalid author string. Must be in the format: " + "John Smith " + ) + name = m.group("name") email = m.group("email") @@ -174,6 +180,12 @@ def _get_maintainer(self): # type: () -> dict m = AUTHOR_REGEX.match(normalize("NFC", self._maintainers[0])) + if m is None: + raise ValueError( + "Invalid maintainer string. Must be in the format: " + "John Smith " + ) + name = m.group("name") email = m.group("email") diff --git a/tests/packages/test_package.py b/tests/packages/test_package.py index 54221eca4c8..19226f81c3d 100644 --- a/tests/packages/test_package.py +++ b/tests/packages/test_package.py @@ -30,6 +30,19 @@ def test_package_authors(): assert package.author_email is None +def test_package_authors_invalid(): + package = Package("foo", "0.1.0") + + package.authors.insert(0, "" + ) + + @pytest.mark.parametrize("category", ["main", "dev"]) def test_package_add_dependency_vcs_category(category): package = Package("foo", "0.1.0")