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

Description cannot contain a newline. #2470

Merged
merged 1 commit into from Jan 17, 2021

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Dec 6, 2020

Quick fix for #1390.

This surgical fix addresses the reported and most common validation failure reported in that issue while a more complete solution is developed in pypa/packaging#147.

No tests are added, though I tested the behavior manually:

setuptools master $ .tox/python/bin/python -c "import setuptools; setuptools.setup(description='a\\nb')" egg_info
running egg_info
writing setuptools.egg-info/PKG-INFO
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/command/egg_info.py", line 291, in run
    writer(self, ep.name, os.path.join(self.egg_info, ep.name))
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/command/egg_info.py", line 623, in write_pkg_info
    metadata.write_pkg_info(cmd.egg_info)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 1117, in write_pkg_info
    self.write_pkg_file(pkg_info)
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/dist.py", line 138, in write_pkg_file
    write_field('Summary', single_line(self.get_description()))
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/dist.py", line 123, in single_line
    raise ValueError("newlines not allowed")
ValueError: newlines not allowed

My main concern and reason for review is to determine:

  • Should this change be backward-incompatible? It will break existing packages that have newlines in their descriptions.
  • Perhaps instead of a hard error it should just emit a warning.

@di
Copy link
Sponsor Member

di commented Dec 6, 2020

This isn't limited to just the Summary field. From #1390 (comment):

Just wanted to point out that this is not limited to just the Summary field -- any field with a double newline will cause the rest of the PKG-INFO file after those newlines to be interpreted as the "message body" and thus become the Long-Description.

Really this should be applied to all fields except Long-Description I think.

@jaraco
Copy link
Member Author

jaraco commented Dec 6, 2020

Acknowledged it potentially affects many fields. I decided to restrict to the reported field as that appears to be the only one that seems to attract the invalid usage. My plan is to apply to this field, and if there are subsequent reports of the same issue with other fields, then expand the scope of the change to all potentially-affected fields, but otherwise await validation from packaging. I'm trying to balance adding a limited fix for known issues with developing the complete solution.

Incidentally, I'm also not particularly happy with the validate-on-write; I'd rather validation happen sooner.

@jaraco jaraco changed the base branch from master to main December 12, 2020 17:16
@jaraco jaraco force-pushed the bugfix/1390-description-no-newlines branch from 904f4a1 to d01d3ee Compare January 17, 2021 00:00
@jaraco jaraco merged commit b5bb3e9 into main Jan 17, 2021
@jaraco jaraco deleted the bugfix/1390-description-no-newlines branch January 17, 2021 00:14
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.

None yet

2 participants