Skip to content

RST cannot contain header only - cause silent crash #149

@kamichal

Description

@kamichal

If the source README.rst contains header only, e.g.:

Header
======

The twine check command claims the markup is invalid for no reason:

twine check 'dist/*'
Checking distribution dist/foo-0.0.1.tar.gz: Failed
The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:

Without listing any errors. Thats the end of stdout/stderr.

If I change the README.rst by adding just single letter at end, e.g.:

Header
======
a

or clear it contents everything is ok:

twine check 'dist/*'
Checking distribution dist/grot-0.0.1.tar.gz: Passed

I debugged it a bit. And got to the line 99 in site-packages/readme_renderer/rst.py:
rendered = parts.get("docinfo", "") + parts.get("fragment", "")
and the rendered string is empty. (both docinfo and fragment contain empty strings).
It corrupts the later if:

    if rendered:
        return clean(rendered)
    else:
        return None

...causing render function return None, which is interpreted by twine.check as error, but no warnings/errors are collected by used stream.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions