Skip to content

Honor but deprecate newlines when processing keywords/platforms#347

Merged
jaraco merged 5 commits into
pypa:mainfrom
frenzymadness:multiline_keywords
Jul 5, 2026
Merged

Honor but deprecate newlines when processing keywords/platforms#347
jaraco merged 5 commits into
pypa:mainfrom
frenzymadness:multiline_keywords

Conversation

@frenzymadness

Copy link
Copy Markdown
Contributor

Newlines in keywords or platforms can break
the produced metadata in PKG-INFO or METADATA files.

Fixes: pypa/setuptools#4887

Another possibility is to raise an error if keywords or platforms contain newlines but this fix is simple and backward-compatible and does not break projects that have multiline definitions of those attributes.

Newlines in `keywords` or `platforms` can break
the produced metadata in PKG-INFO or METADATA files.

Fixes: pypa/setuptools#4887
@jaraco

jaraco commented May 4, 2025

Copy link
Copy Markdown
Member

Thanks for this proposal. My instinct is it would be better to guide users toward one best format, preferably something with proper syntax support, i.e. a full sequence of values, whether in Python or toml. What do you think about instead deprecating anything but sequence[str] for keywords & platforms?

Comment thread distutils/dist.py Outdated
Comment thread newsfragments/4887.bugfix.rst Outdated
Comment thread newsfragments/4887.bugfix.rst Outdated
Comment thread distutils/dist.py Outdated
Rather than silently joining newline-separated items with spaces, treat
each line as a separate item (replacing newlines with commas) and warn
that the behavior is deprecated, since newlines were never a valid
separator for these fields. Extract the repair into a documented helper.

Ref pypa/setuptools#4887

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jaraco jaraco changed the title Ignore newlines when processing keywords/platforms Honor but deprecate newlines when processing keywords/platforms Jul 5, 2026
Comment thread distutils/tests/test_dist.py Outdated
Comment thread distutils/dist.py
- Emit a plain (UserWarning) rather than DeprecationWarning, which is
  suppressed by default and wouldn't reach setuptools users (per the
  distutils.log.Log precedent).
- Drop empty items so consecutive/leading/trailing newlines don't create
  blank keywords; cover this in the tests.
- Reframe the news and docstring as forgiving invalid input rather than
  implying newlines followed any specification.
Comment thread distutils/dist.py Outdated
jaraco added 2 commits July 5, 2026 11:21
Replace the hand-rolled comma split/strip/drop-empties with the reusable
jaraco.text.SeparatedValues, promoting jaraco.text to a runtime dependency.
_repair_newlines still handles the invalid-newline repair and deprecation.
@jaraco jaraco merged commit 56d23a3 into pypa:main Jul 5, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] multiline keywords breaks metadata file

3 participants