Skip to content

pydoc -k IndexError on empty docstring #65747

Closed

Description

@dimaqq
mannequin
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']

    Activity

    1. dimaqq commented on May 21, 2014

      dimaqqmannequin
      MannequinAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on May 21, 2014
    3. terryjreedy commented on May 23, 2014

      @terryjreedy
      Member

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

    4. YuyangGuo commented on Jun 7, 2014

      YuyangGuomannequin
      Mannequin

      Made change based on Terry J. Reedy's suggestion

    5. benjaminp commented on Jun 7, 2014

      @benjaminp
      Contributor

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

    6. berkerpeksag commented on Jan 25, 2015

      @berkerpeksag
      Member

      Here's a patch with tests.

    7. serhiy-storchaka commented on Feb 16, 2015

      @serhiy-storchaka
      Member

      LGTM.

    8. python-dev commented on Feb 17, 2015

      python-devmannequin
      Mannequin

      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

    9. python-dev commented on Feb 20, 2015

      python-devmannequin
      Mannequin

      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

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      easystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions