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

pydoc -k IndexError on empty docstring #65747

Closed
dimaqq mannequin opened this issue May 21, 2014 · 8 comments
Closed

pydoc -k IndexError on empty docstring #65747

dimaqq mannequin opened this issue May 21, 2014 · 8 comments
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@dimaqq
Copy link
Mannequin

dimaqq mannequin commented May 21, 2014

BPO 21548
Nosy @terryjreedy, @benjaminp, @berkerpeksag, @dimaqq, @serhiy-storchaka
Files
  • issue21548.patch
  • issue21548.diff
  • 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 = None
    closed_at = <Date 2015-02-20.10:10:26.778>
    created_at = <Date 2014-05-21.08:43:03.290>
    labels = ['easy', 'type-bug', 'library']
    title = 'pydoc -k IndexError on empty docstring'
    updated_at = <Date 2015-02-20.10:10:26.777>
    user = 'https://github.com/dimaqq'

    bugs.python.org fields:

    activity = <Date 2015-02-20.10:10:26.777>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-02-20.10:10:26.778>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2014-05-21.08:43:03.290>
    creator = 'Dima.Tisnek'
    dependencies = []
    files = ['35516', '37841']
    hgrepos = []
    issue_num = 21548
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['218865', '218998', '219956', '219971', '234641', '236117', '236119', '236261']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'benjamin.peterson', 'python-dev', 'berker.peksag', 'Dima.Tisnek', 'serhiy.storchaka', 'Yuyang.Guo']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21548'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @dimaqq
    Copy link
    Mannequin Author

    dimaqq mannequin commented May 21, 2014

    While trying to track down another bug, I disabled some packages:

    [dima@bmg tmp]$ chmod a-x /usr/lib/python3.4/site-packages/speechd*

    Then ran pydoc -k:

    [dima@bmg tmp]$ pydoc3.4 -k n688954789
    Traceback (most recent call last):
      File "/usr/bin/pydoc3.4", line 5, in <module>
        pydoc.cli()
      File "/usr/lib/python3.4/pydoc.py", line 2548, in cli
        apropos(val)
      File "/usr/lib/python3.4/pydoc.py", line 2080, in apropos
        ModuleScanner().run(callback, key, onerror=onerror)
      File "/usr/lib/python3.4/pydoc.py", line 2061, in run
        desc = (module.__doc__ or '').splitlines()[0]
    IndexError: list index out of range

    Clearly "".splitlines() is always empty; missing doc is not handled correctly.

    @dimaqq dimaqq mannequin added the stdlib Python modules in the Lib dir label May 21, 2014
    @terryjreedy
    Copy link
    Member

    Replacing 2061 with the following should work for all versions.
    desc = module.__doc__.splitlines()[0] if module.__doc__ else ''

    @terryjreedy terryjreedy added the type-bug An unexpected behavior, bug, or error label May 23, 2014
    @bitdancer bitdancer added the easy label Jun 2, 2014
    @YuyangGuo
    Copy link
    Mannequin

    YuyangGuo mannequin commented Jun 7, 2014

    Made change based on Terry J. Reedy's suggestion

    @benjaminp
    Copy link
    Contributor

    Thanks for the patch! It looks like the "synopsis" function also has this bug. Could you fix that, too?

    @berkerpeksag
    Copy link
    Member

    Here's a patch with tests.

    @serhiy-storchaka
    Copy link
    Member

    LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 17, 2015

    New changeset 9436f43b6df2 by Benjamin Peterson in branch '3.4':
    fix pydoc.apropos and pydoc.synopsis on modules with empty docstrings (bpo-21548)
    https://hg.python.org/cpython/rev/9436f43b6df2

    New changeset 534b26837a13 by Benjamin Peterson in branch 'default':
    merge 3.4 (bpo-21548)
    https://hg.python.org/cpython/rev/534b26837a13

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 20, 2015

    New changeset 43641e03692a by Berker Peksag in branch '2.7':
    Issue bpo-21548: Fix pydoc.synopsis() and pydoc.apropos() on modules with empty
    https://hg.python.org/cpython/rev/43641e03692a

    @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
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants