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

subprocess.check_output: "docstring has inconsistent leading whitespace" #51630

Closed
florentx mannequin opened this issue Nov 23, 2009 · 8 comments
Closed

subprocess.check_output: "docstring has inconsistent leading whitespace" #51630

florentx mannequin opened this issue Nov 23, 2009 · 8 comments
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir tests Tests in the Lib/test dir

Comments

@florentx
Copy link
Mannequin

florentx mannequin commented Nov 23, 2009

BPO 7381
Nosy @birkenfeld, @florentx
Files
  • issue7381_v2.diff: Patch, apply to trunk
  • issue7381_py3k_v2.diff: Patch, apply to py3k
  • issue7381_v3.diff: Patch, apply to trunk
  • issue7381_py3k_v3.diff: Patch, apply to py3k
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/birkenfeld'
    closed_at = <Date 2009-12-28.08:10:39.103>
    created_at = <Date 2009-11-23.13:28:36.231>
    labels = ['tests', 'library', 'docs']
    title = 'subprocess.check_output: "docstring has inconsistent leading whitespace"'
    updated_at = <Date 2009-12-28.08:10:39.102>
    user = 'https://github.com/florentx'

    bugs.python.org fields:

    activity = <Date 2009-12-28.08:10:39.102>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2009-12-28.08:10:39.103>
    closer = 'georg.brandl'
    components = ['Documentation', 'Library (Lib)', 'Tests']
    creation = <Date 2009-11-23.13:28:36.231>
    creator = 'flox'
    dependencies = []
    files = ['15580', '15581', '15624', '15625']
    hgrepos = []
    issue_num = 7381
    keywords = ['patch']
    message_count = 8.0
    messages = ['95625', '95626', '95627', '95636', '95938', '96511', '96687', '96940']
    nosy_count = 2.0
    nosy_names = ['georg.brandl', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue7381'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2']

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Nov 23, 2009

    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/subprocess.py
    ...............
    ----------------------------------------------------------------------
    Ran 15 tests in 0.012s

    OK
    ~ $ python3 -m doctest /usr/lib/python3.1/subprocess.py
    Traceback (most recent call last):
      File "/usr/lib/python3.1/runpy.py", line 128, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "/usr/lib/python3.1/runpy.py", line 34, in _run_code
        exec(code, run_globals)
      File "/usr/lib/python3.1/doctest.py", line 2637, in <module>
        sys.exit(_test())
      File "/usr/lib/python3.1/doctest.py", line 2626, in _test
        failures, _ = testmod(m)
      File "/usr/lib/python3.1/doctest.py", line 1847, in testmod
        for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
      File "/usr/lib/python3.1/doctest.py", line 854, in find
        self._find(tests, obj, name, module, source_lines, globs, {})
      File "/usr/lib/python3.1/doctest.py", line 908, in _find
        globs, seen)
      File "/usr/lib/python3.1/doctest.py", line 896, in _find
        test = self._get_test(obj, name, module, globs, source_lines)
      File "/usr/lib/python3.1/doctest.py", line 980, in _get_test
        filename, lineno)
      File "/usr/lib/python3.1/doctest.py", line 590, in get_doctest
        return DocTest(self.get_examples(string, name), globs,
      File "/usr/lib/python3.1/doctest.py", line 604, in get_examples
        return [x for x in self.parse(string, name)
      File "/usr/lib/python3.1/doctest.py", line 566, in parse
        self._parse_example(m, name, lineno)
      File "/usr/lib/python3.1/doctest.py", line 636, in _parse_example
        lineno + len(source_lines))
      File "/usr/lib/python3.1/doctest.py", line 722, in _check_prefix
        (lineno+i+1, name, line))
    ValueError: line 11 of the docstring for subprocess.check_output has
    inconsistent leading whitespace: "'"

    @florentx florentx mannequin added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir labels Nov 23, 2009
    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Nov 23, 2009

    I fixed the docstring inconsistency (see patch) and some obvious things.

    But I still have errors.

    ~ $ python3 -m doctest py3_failed/subprocess.py


    File "py3_failed/subprocess.py", line 139, in subprocess
    Failed example:
    subprocess.getstatusoutput('/bin/junk')
    Expected:
    (256, 'sh: /bin/junk: not found')
    Got:
    (32512, '/bin/sh: /bin/junk: No such file or directory')


    File "py3_failed/subprocess.py", line 449, in subprocess.check_output
    Failed example:
    check_output(["ls", "-l", "/dev/null"])
    Expected:
    b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
    Got:
    b'crw-rw-rw- 1 root root 1, 3 Nov 15 17:41 /dev/null\n'


    File "py3_failed/subprocess.py", line 455, in subprocess.check_output
    Failed example:
    check_output(["/bin/sh", "-c",
    "ls -l non_existent_file ; exit 0"],
    stderr=STDOUT)
    Expected:
    b'ls: non_existent_file: No such file or directory\n'
    Got:
    b'ls: cannot access non_existent_file: No such file or directory\n'


    File "py3_failed/subprocess.py", line 559, in subprocess.getstatusoutput
    Failed example:
    subprocess.getstatusoutput('/bin/junk')
    Expected:
    (256, 'sh: /bin/junk: not found')
    Got:
    (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.
    ~ $

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Nov 23, 2009

    It may be fixed with "# doctest: +ELLIPSIS" and "# doctest: +SKIP"
    directives...
    But it is probably platform-dependent.

    I have tested only with Debian Lenny.

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Nov 23, 2009

    Forget the "python2.5 -m doctest /usr/lib/python2.5/subprocess.py" 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).

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Dec 3, 2009

    Patch against the trunk, and against the Py3k branch.

    It fixes:

    • docstring and documentation formatting
    • and examples

    @florentx florentx mannequin added the docs Documentation in the Doc dir label Dec 3, 2009
    @florentx florentx mannequin assigned birkenfeld Dec 3, 2009
    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Dec 17, 2009

    Patch updated to backport r51536 in trunk.
    It makes "python -3" happier (do not compare None >= 0).

    @florentx
    Copy link
    Mannequin Author

    florentx mannequin commented Dec 20, 2009

    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

    @birkenfeld
    Copy link
    Member

    OK, applied in r77086, r77087.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir stdlib Python modules in the Lib dir tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant