Skip to content

Commit 9804370

Browse files
committed
Fixes pypa#920. Don't replace unserscores with hyphens in distribution name.
1 parent 8f5e5d6 commit 9804370

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

tests/test_package.py

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def test_package_signed_name_is_correct():
121121
(string.digits, string.digits),
122122
(string.punctuation, "-.-"),
123123
("mosaik.SimConfig", "mosaik.SimConfig"),
124+
("package_name", "package_name"),
124125
("mosaik$$$$.SimConfig", "mosaik-.SimConfig"),
125126
],
126127
)

twine/package.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
def _safe_name(name: str) -> str:
5252
"""Convert an arbitrary string to a standard distribution name.
5353
54-
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
54+
Any runs of non-alphanumeric/./_ characters are replaced with a single '-'.
5555
5656
Copied from pkg_resources.safe_name for compatibility with warehouse.
5757
See https://github.com/pypa/twine/issues/743.
5858
"""
59-
return re.sub("[^A-Za-z0-9.]+", "-", name)
59+
return re.sub("[^A-Za-z0-9._]+", "-", name)
6060

6161

6262
class PackageFile:

0 commit comments

Comments
 (0)