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

wheel.pkginfo.write_pkg_info should set mangle_from_ to False; the default causes rendering issues #178

Closed
agronholm opened this issue Jan 27, 2017 · 1 comment

Comments

@agronholm
Copy link
Contributor

Originally reported by: Jason Madden (Bitbucket: jamadden, GitHub: jamadden)


Long Description

There was a bug report against twine where a user complained that the description for an uploaded project was rendered incorrectly when the wheel was uploaded, but rendered correctly when only the sdist was uploaded.

Tracking this down, it turns out that creating the METADATA in the wheel mangles the description un-renderable if a line just so happens to start with "From" and be a header.

wheel uses email.generator to write the METADATA file. By default, email.generator will write files compatible with Unix mbox format, which means that lines that begin with "From" are mangled to be ">From" (to indicate that they do not begin a new message in the multi-message mbox format). (sdists don't have this problem because the description is in a "header" and headers aren't mangled.)

The METADATA file can only ever be one message, so this is not a concern. (Even if it was, the pkginfo library uses email.parser to read the METADATA files, which doesn't support this convention.)

Example

Mangling "From" to ">From" causes rendering issues when the line happens to be a header.

Take this perfectly correct RST document:

======
 Head
======

Body 1


From Place
----------

A place

Mangle the from line:

======
 Head
======

Body 1


>From Place
----------

A place

Increasing the length of the line makes the underline too short and rendering fails with "Bad.rst:17: (WARNING/2) Title underline too short." (This was verified using rstview which uses readme-renderer.)

Proposed Fix

The simple fix is to pass mangle_from_=False to the email.generator.Generator object used to write the file (in wheel.pkginfo.write_pkg_info, I think). This eliminates the mangling. This parameter is available all the way back to 2.6.


@agronholm
Copy link
Contributor Author

Thanks for the analysis and the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant