Title: subprocess.check_output: "docstring has inconsistent leading whitespace"
Type: Stage:
Components: Documentation, Library (Lib), Tests Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: flox, georg.brandl
Priority: normal Keywords: patch

Created on 2009-11-23 13:28 by flox, last changed 2009-12-28 08:10 by georg.brandl. This issue is now closed.

File name Uploaded Description Edit
issue7381_v2.diff flox, 2009-12-17 11:28 Patch, apply to trunk
issue7381_py3k_v2.diff flox, 2009-12-17 11:29 Patch, apply to py3k
issue7381_v3.diff flox, 2009-12-20 15:21 Patch, apply to trunk
issue7381_py3k_v3.diff flox, 2009-12-20 15:21 Patch, apply to py3k
Messages (8)
msg95625 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-11-23 13:28
I've tested the docstring of the module subprocess.
Python 2.5 is OK, but Python 3.1 fails.

~ $ python2.5 -m doctest /usr/lib/python2.5/
Ran 15 tests in 0.012s

~ $ python3 -m doctest /usr/lib/python3.1/
Traceback (most recent call last):
  File "/usr/lib/python3.1/", line 128, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python3.1/", line 34, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.1/", line 2637, in <module>
  File "/usr/lib/python3.1/", line 2626, in _test
    failures, _ = testmod(m)
  File "/usr/lib/python3.1/", line 1847, in testmod
    for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
  File "/usr/lib/python3.1/", line 854, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "/usr/lib/python3.1/", line 908, in _find
    globs, seen)
  File "/usr/lib/python3.1/", line 896, in _find
    test = self._get_test(obj, name, module, globs, source_lines)
  File "/usr/lib/python3.1/", line 980, in _get_test
    filename, lineno)
  File "/usr/lib/python3.1/", line 590, in get_doctest
    return DocTest(self.get_examples(string, name), globs,
  File "/usr/lib/python3.1/", line 604, in get_examples
    return [x for x in self.parse(string, name)
  File "/usr/lib/python3.1/", line 566, in parse
    self._parse_example(m, name, lineno)
  File "/usr/lib/python3.1/", line 636, in _parse_example
    lineno + len(source_lines))
  File "/usr/lib/python3.1/", line 722, in _check_prefix
    (lineno+i+1, name, line))
ValueError: line 11 of the docstring for subprocess.check_output has
inconsistent leading whitespace: "'"
msg95626 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-11-23 13:39
I fixed the docstring inconsistency (see patch) and some obvious things.

But I still have errors.

~ $ python3 -m doctest py3_failed/
File "py3_failed/", line 139, in subprocess
Failed example:
    (256, 'sh: /bin/junk: not found')
    (32512, '/bin/sh: /bin/junk: No such file or directory')
File "py3_failed/", line 449, in subprocess.check_output
Failed example:
    check_output(["ls", "-l", "/dev/null"])
    b'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
    b'crw-rw-rw- 1 root root 1, 3 Nov 15 17:41 /dev/null\n'
File "py3_failed/", line 455, in subprocess.check_output
Failed example:
    check_output(["/bin/sh", "-c",
                  "ls -l non_existent_file ; exit 0"],
    b'ls: non_existent_file: No such file or directory\n'
    b'ls: cannot access non_existent_file: No such file or directory\n'
File "py3_failed/", line 559, in subprocess.getstatusoutput
Failed example:
    (256, 'sh: /bin/junk: not found')
    (32512, '/bin/sh: /bin/junk: No such file or directory')
3 items had failures:
   1 of   6 in subprocess
   2 of   2 in subprocess.check_output
   1 of   4 in subprocess.getstatusoutput
***Test Failed*** 4 failures.
~ $
msg95627 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-11-23 13:45
It may be fixed with "# doctest: +ELLIPSIS" and "# doctest: +SKIP"
But it is probably platform-dependent.

I have tested only with Debian Lenny.
msg95636 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-11-23 16:40
Forget the "python2.5 -m doctest /usr/lib/python2.5/" in
first message msg95625.
This command does not do what I guessed. And there's no doctest in the
Python2.5 "subprocess" module.

The attached patch may be enough to fix the docstring inconsistencies
with Python3.1.
It might not be mandatory to make the docstring 100% successful.
(I see no PEP which requires that).
msg95938 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-03 18:28
Patch against the trunk, and against the Py3k branch.

It fixes:
 * docstring and documentation formatting
 * and examples
msg96511 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-17 11:28
Patch updated to backport r51536 in trunk.
It makes "python -3" happier (do not compare None >= 0).
msg96687 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-20 15:21
Committed to r76925 (trunk) and r76926 (py3k).

Thank you Georg.

I see small remaining inconsistencies in the docstring.
Either we agree with implicit "import subprocess" or "from subprocess
import *", but we should not mix both.

See additional patches:
 * issue7381_v3.diff
 * issue7381_py3k_v3.diff
msg96940 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-12-28 08:10
OK, applied in r77086, r77087.
Date User Action Args
2009-12-28 08:10:39georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg96940
2009-12-20 15:21:43floxsetfiles: + issue7381_py3k_v3.diff
2009-12-20 15:21:12floxsetfiles: + issue7381_v3.diff

messages: + msg96687
2009-12-17 11:30:02floxsetfiles: - issue7381.diff
2009-12-17 11:29:58floxsetfiles: - issue7381_py3k.diff
2009-12-17 11:29:37floxsetfiles: + issue7381_py3k_v2.diff
2009-12-17 11:29:00floxsetfiles: + issue7381_v2.diff

messages: + msg96511
2009-12-03 18:28:22floxsetfiles: + issue7381_py3k.diff
2009-12-03 18:28:05floxsetfiles: + issue7381.diff

assignee: georg.brandl
components: + Documentation
versions: + Python 2.6, Python 2.7
nosy: + georg.brandl

messages: + msg95938
2009-12-03 18:24:11floxsetfiles: - issue7381_first.diff
2009-11-23 16:40:46floxsetmessages: + msg95636
2009-11-23 13:45:43floxsetmessages: + msg95627
2009-11-23 13:39:59floxsetfiles: + issue7381_first.diff
keywords: + patch
messages: + msg95626
2009-11-23 13:28:36floxcreate