From 980437050ef355905fe026c1a5d0e2e8e32fabd0 Mon Sep 17 00:00:00 2001 From: navrkald Date: Tue, 16 Aug 2022 13:42:00 +0200 Subject: [PATCH] Fixes #920. Don't replace unserscores with hyphens in distribution name. --- tests/test_package.py | 1 + twine/package.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_package.py b/tests/test_package.py index 0b883da3..9ac47fd8 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -121,6 +121,7 @@ def test_package_signed_name_is_correct(): (string.digits, string.digits), (string.punctuation, "-.-"), ("mosaik.SimConfig", "mosaik.SimConfig"), + ("package_name", "package_name"), ("mosaik$$$$.SimConfig", "mosaik-.SimConfig"), ], ) diff --git a/twine/package.py b/twine/package.py index 3ca074fe..7caad349 100644 --- a/twine/package.py +++ b/twine/package.py @@ -51,12 +51,12 @@ def _safe_name(name: str) -> str: """Convert an arbitrary string to a standard distribution name. - Any runs of non-alphanumeric/. characters are replaced with a single '-'. + Any runs of non-alphanumeric/./_ characters are replaced with a single '-'. Copied from pkg_resources.safe_name for compatibility with warehouse. See https://github.com/pypa/twine/issues/743. """ - return re.sub("[^A-Za-z0-9.]+", "-", name) + return re.sub("[^A-Za-z0-9._]+", "-", name) class PackageFile: