diff --git a/src/poetry/core/factory.py b/src/poetry/core/factory.py index 04cb5873d..b837e4278 100644 --- a/src/poetry/core/factory.py +++ b/src/poetry/core/factory.py @@ -9,6 +9,7 @@ from typing import Union from warnings import warn +from poetry.core.utils.helpers import combine_unicode from poetry.core.utils.helpers import readme_content_type @@ -76,10 +77,10 @@ def configure_package( package.root_dir = root for author in config["authors"]: - package.authors.append(author) + package.authors.append(combine_unicode(author)) for maintainer in config.get("maintainers", []): - package.maintainers.append(maintainer) + package.maintainers.append(combine_unicode(maintainer)) package.description = config.get("description", "") package.homepage = config.get("homepage") diff --git a/src/poetry/core/utils/helpers.py b/src/poetry/core/utils/helpers.py index af2f9bbda..769f663ec 100644 --- a/src/poetry/core/utils/helpers.py +++ b/src/poetry/core/utils/helpers.py @@ -3,6 +3,7 @@ import shutil import stat import tempfile +import unicodedata from collections.abc import Mapping from contextlib import contextmanager @@ -20,6 +21,10 @@ _canonicalize_regex = re.compile(r"[-_]+") +def combine_unicode(string: str) -> str: + return unicodedata.normalize("NFC", string) + + def canonicalize_name(name: str) -> str: return _canonicalize_regex.sub("-", name).lower() diff --git a/tests/fixtures/sample_project/pyproject.toml b/tests/fixtures/sample_project/pyproject.toml index b2911d645..a99e6c19d 100644 --- a/tests/fixtures/sample_project/pyproject.toml +++ b/tests/fixtures/sample_project/pyproject.toml @@ -3,7 +3,7 @@ name = "my-package" version = "1.2.3" description = "Some description." authors = [ - "Sébastien Eustace " + "Sébastien Eustace " ] license = "MIT" diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index 662a618ef..02d8dc1d6 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -7,6 +7,7 @@ import pytest from poetry.core.utils.helpers import canonicalize_name +from poetry.core.utils.helpers import combine_unicode from poetry.core.utils.helpers import parse_requires from poetry.core.utils.helpers import readme_content_type from poetry.core.utils.helpers import temporary_directory @@ -76,6 +77,15 @@ def test_utils_helpers_canonical_names(raw: str): assert canonicalize_name(raw) == "a-b-c" +def test_utils_helpers_combine_unicode(): + combined_expected = "é" + decomposed = "é" + assert combined_expected != decomposed + + combined = combine_unicode(decomposed) + assert combined == combined_expected + + def test_utils_helpers_temporary_directory_readonly_file(): with temporary_directory() as temp_dir: readonly_filename = os.path.join(temp_dir, "file.txt")