Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail on a multiline distribution package summary #2870

Merged
merged 5 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2870.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Started failing on invalid inline description with line breaks :class:`ValueError` -- by :user:`webknjaz`
8 changes: 4 additions & 4 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ def read_pkg_file(self, file):


def single_line(val):
# quick and dirty validation for description pypa/setuptools#1390
"""Validate that the value does not have line breaks."""
# Ref: https://github.com/pypa/setuptools/issues/1390
if '\n' in val:
# TODO after 2021-07-31: Replace with `raise ValueError("newlines not allowed")`
warnings.warn("newlines not allowed and will break in the future")
val = val.replace('\n', ' ')
raise ValueError('Newlines are not allowed')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this wording is that it doesn't help figure out what's wrong. When I saw a warning in the middle of the console output, the only way to understand what it was, was to read the source code. This is not the best UX, is it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it's not the best user experience. But I expect these errors to be rare. Also, now that they're raised as an exception (or if you'd passed -We), you'll see the traceback, which does point to single_line(self.get_description()), which does indicate where the error is.


return val


Expand Down