[New-bugs-announce] [issue23063] `python setup.py check --restructuredtext --strict --metadata` fails with: `warning: check: Could not finish the parsing.` if the RST document uses code or code-block directives.

Marc Abramowitz report at bugs.python.org
Tue Dec 16 08:58:05 CET 2014


New submission from Marc Abramowitz:

`python setup.py check --restructuredtext --strict --metadata` fails with:

    warning: check: Could not finish the parsing.

if the RST document uses `code` or `code-block` directives.

This is annoying because the document is valid, but it appears to be invalid
and confuses people. For example, see
https://github.com/ionelmc/pytest-benchmark/pull/4#issuecomment-66940307

How to reproduce this bug
-------------------------

Clone a repo that has a `README.rst` with `code-block` directives in it. E.g.:

    $ git clone git at github.com:ionelmc/pytest-benchmark.git
    $ cd pytest-benchmark
    $ git checkout ab0b08f6fccb06a7909905a8409f8faa8b01e0d8

   Observe that it has "code-blocks" in it:

       $ grep 'code-block' README.rst
       .. code-block:: python
       .. code-block:: python

Observe that RST document is valid, according to `rst2html.py`:

       $ rst2html.py --halt=1 README.rst > README.html && echo "RST was OK."
       RST was OK.

       $ head -n 3 README.html
       <?xml version="1.0" encoding="utf-8" ?>
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Observe that `python setup.py check --restructuredtext --strict --metadata` fails:

    $ python setup.py check --restructuredtext --strict --metadata
    running check
    warning: check: Could not finish the parsing.

    error: Please correct your package.

    $ echo $?
    1

**What was expected**: `python setup.py check --restructuredtext --strict
--metadata` should succeed with no warnings, just as `rst2html.py did`, because
`README.rst` is a valid RST document.

**What actually happened**: `python setup.py check --restructuredtext --strict
--metadata` prints a warning and an error and fails, unlike `rst2html.py`

The error is coming from here:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L142

It's happening because of this line:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L125

    :::python
    settings = frontend.OptionParser().get_default_values()

If this is changed to:

    :::python
    settings = frontend.OptionParser(components=(Parser,)).get_default_values()

then things work much better (this is how `tools/quicktest.py` in docutils does it for example -- see https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/tools/quicktest.py#l196)

The attached patch prevents the failure from happening and also adds more information to the error when things go south.

----------
components: Distutils
hgrepos: 286
messages: 232720
nosy: Marc.Abramowitz, dstufft, eric.araujo
priority: normal
severity: normal
status: open
title: `python setup.py check --restructuredtext --strict --metadata` fails with: `warning: check: Could not finish the parsing.` if the RST document uses code or code-block directives.
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23063>
_______________________________________


More information about the New-bugs-announce mailing list