This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Marc.Abramowitz
Recipients Marc.Abramowitz, dstufft, eric.araujo
Date 2014-12-16.07:58:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1418716685.25.0.847417973192.issue23063@psf.upfronthosting.co.za>
In-reply-to
Content
`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@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.
History
Date User Action Args
2014-12-16 07:58:05Marc.Abramowitzsetrecipients: + Marc.Abramowitz, eric.araujo, dstufft
2014-12-16 07:58:05Marc.Abramowitzsetmessageid: <1418716685.25.0.847417973192.issue23063@psf.upfronthosting.co.za>
2014-12-16 07:58:05Marc.Abramowitzlinkissue23063 messages
2014-12-16 07:58:04Marc.Abramowitzcreate