Skip to content

Commit fdbd7f9

Browse files
committed
Ignore newlines when processing keywords/platforms
Newlines in `keywords` or `platforms` can break the produced metadata in PKG-INFO or METADATA files. Fixes: pypa#4887
1 parent 07e96b1 commit fdbd7f9

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

newsfragments/4887.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed handling of keywords following the old specification with spaces instead of commas and containing newlines.

setuptools/_distutils/dist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ def finalize_options(self) -> None:
644644
if value is None:
645645
continue
646646
if isinstance(value, str):
647+
value = value.replace("\n", " ")
647648
value = [elm.strip() for elm in value.split(',')]
648649
setattr(self.metadata, attr, value)
649650

setuptools/tests/test_core_metadata.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,30 @@ def __read_test_cases():
164164
version=sic('1.0.0a'),
165165
),
166166
),
167+
(
168+
'Keywords with commas',
169+
params(
170+
keywords='one, two, three',
171+
),
172+
),
173+
(
174+
'Keywords with spaces',
175+
params(
176+
keywords='one two three',
177+
),
178+
),
179+
(
180+
'Keywords with commas multiline',
181+
params(
182+
keywords='one, two,\nthree, four\n',
183+
),
184+
),
185+
(
186+
'Keywords with spaces multiline',
187+
params(
188+
keywords='one two\nthree four\n',
189+
),
190+
),
167191
]
168192

169193

0 commit comments

Comments
 (0)