Newlines in the `description` field produce a malformed PKG-INFO
See original GitHub issueWe discovered this accidentally by way of https://github.com/zopefoundation/zc.relation/issues/4#issuecomment-397532224: if you pass a string containing newlines to the description
argument of setup()
, setuptools will generate a malformed PKG-INFO.
To reproduce:
# setup.py
from setuptools import setup
setup(
name='test-package',
version='0.1',
author='Blah Blah',
author_email='blah@example.com',
description='description\n\n',
py_modules=['blah'],
)
(The contents of blah.py
do not matter, but the file should exist.)
Run python setup.py sdist
and the inspect test_package.egg-info/PKG-INFO
. For me, with setuptools 39.1.0, it looks like this:
Metadata-Version: 1.0
Name: test-package
Version: 0.1
Summary: description
Home-page: UNKNOWN
Author: Blah Blah
Author-email: blah@example.com
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
The extra newlines lead tools to treat the rest of the PKG-INFO as a long_description.
I would expect setuptools
to complain about the newlines in the description
field, or at least escape them properly (i.e. prepend whitespace, like it does for the long_description
field).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:42 (22 by maintainers)
Top Results From Across the Web
Solved: Automation rule encountered newline and failed
Solved: Is there a way to copy a field (i.e. the Summary) during a rule to create a new issue WITHOUT encountering this...
Read more >How to add a line break to the description field o... - ServiceNow
For this catalog item I am working on, for the description they want essentially multiple sentences to be showing on their own with...
Read more >Newline - Wikipedia
Newline is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc.
Read more >REST api new Task with newlines in Description field
Using PowerShell and the REST api I'm creating new work item Tasks in ADS. I want the Description field to include line breaks, ......
Read more >How to add line-break in the google groups description field?
The last thing you can try is to URI encode the '\n' using %0A . This seems to have been successfully used in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We should fail hard for configurations that are invalid. There should be an error message that gives a clear indication on how to fix the problem. This is a developer API, and developers should deal with their broken code. We shouldn’t try to guess-fix broken stuff.
Do the fields/kwargs have an explicit specification of the data they expect? This should be enforced. The fields
description
andlicense
obviously expect single-line data. Hence, when a newline is submitted in the data for those fields the generation of PKG-INFO should be aborted with a clear error message, e.g.setuptools 51.3.0 landed and I immediately got some error report about broken (internal) builds.
Reporting error here is not a good idea, really.
Please, don’t go that way. Drop description altogether if you don’t like it and can’t fix it, but don’t break installations. Ecosystem is huge, libraries are plenty, automated builds are numerous…