From f8fe4a873c5d3d89a939c0576e1c14a8e82c73c8 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 11 Nov 2021 03:43:03 +0100 Subject: [PATCH 1/5] Fail on a multiline distribution package summary --- setuptools/dist.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setuptools/dist.py b/setuptools/dist.py index 8e2111a52b..e61733d811 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -144,12 +144,14 @@ def read_pkg_file(self, file): self.license_files = _read_list_from_msg(msg, 'license-file') -def single_line(val): - # quick and dirty validation for description pypa/setuptools#1390 +def ensure_summary_single_line(val): + """Validate that the summary 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 in the package distribution summary are not allowed', + ) + return val @@ -164,7 +166,7 @@ def write_field(key, value): write_field('Metadata-Version', str(version)) write_field('Name', self.get_name()) write_field('Version', self.get_version()) - write_field('Summary', single_line(self.get_description())) + write_field('Summary', ensure_summary_single_line(self.get_description())) write_field('Home-page', self.get_url()) optional_fields = ( From 818fdb91b45e974b0b7a9593df02c2e06f497b10 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 11 Nov 2021 05:05:40 +0100 Subject: [PATCH 2/5] Add a change note for PR #2870 --- changelog.d/2870.change.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2870.change.rst diff --git a/changelog.d/2870.change.rst b/changelog.d/2870.change.rst new file mode 100644 index 0000000000..22a7f218d6 --- /dev/null +++ b/changelog.d/2870.change.rst @@ -0,0 +1 @@ +Started failing on invalid inline description with line brakes :class:`ValueError` -- by :user:`webknjaz` From 65d66538b937b083b276ed7058a779ccfa3c44d8 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Fri, 12 Nov 2021 23:45:58 +0100 Subject: [PATCH 3/5] Fix the word "breaks" in the change note Co-authored-by: Jason R. Coombs --- changelog.d/2870.change.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/2870.change.rst b/changelog.d/2870.change.rst index 22a7f218d6..1d17ede602 100644 --- a/changelog.d/2870.change.rst +++ b/changelog.d/2870.change.rst @@ -1 +1 @@ -Started failing on invalid inline description with line brakes :class:`ValueError` -- by :user:`webknjaz` +Started failing on invalid inline description with line breaks :class:`ValueError` -- by :user:`webknjaz` From a4b7caeaa653116b60a5231e9019ab250293c331 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 12 Nov 2021 19:01:55 -0500 Subject: [PATCH 4/5] Restore single_line as a simple, universal validator. --- setuptools/dist.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/setuptools/dist.py b/setuptools/dist.py index e61733d811..848d6b0f75 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -144,13 +144,11 @@ def read_pkg_file(self, file): self.license_files = _read_list_from_msg(msg, 'license-file') -def ensure_summary_single_line(val): - """Validate that the summary does not have line breaks.""" +def single_line(val): + """Validate that the value does not have line breaks.""" # Ref: https://github.com/pypa/setuptools/issues/1390 if '\n' in val: - raise ValueError( - 'Newlines in the package distribution summary are not allowed', - ) + raise ValueError('Newlines are not allowed') return val @@ -166,7 +164,7 @@ def write_field(key, value): write_field('Metadata-Version', str(version)) write_field('Name', self.get_name()) write_field('Version', self.get_version()) - write_field('Summary', ensure_summary_single_line(self.get_description())) + write_field('Summary', single_line(self.get_description())) write_field('Home-page', self.get_url()) optional_fields = ( From 25d1d5458716f9f80b2c5094461579cfa0fe4469 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 12 Nov 2021 19:03:32 -0500 Subject: [PATCH 5/5] Change is backward-incompatible for projects with newlines in the summary. --- changelog.d/{2870.change.rst => 2870.breaking.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{2870.change.rst => 2870.breaking.rst} (100%) diff --git a/changelog.d/2870.change.rst b/changelog.d/2870.breaking.rst similarity index 100% rename from changelog.d/2870.change.rst rename to changelog.d/2870.breaking.rst