Sitelet https://github.com/python/cpython/issues/84476
Skip to content

help(list[int]) fails #84476

Description

@serhiy-storchaka
BPO 40296
Nosy @gvanrossum, @serhiy-storchaka, @JelleZijlstra, @miss-islington
PRs
  • bpo-40296: Fix supporting generic aliases in pydoc #30253
  • [3.10] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). #31976
  • [3.9] [3.10] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976) #31981
  • Dependencies
  • bpo-47042: Fix test_html_doc in test_pydoc
  • 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 2022-03-19.15:13:37.231>
    created_at = <Date 2020-04-15.20:50:17.005>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'help(list[int]) fails'
    updated_at = <Date 2022-03-19.15:13:37.230>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2022-03-19.15:13:37.230>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-19.15:13:37.231>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2020-04-15.20:50:17.005>
    creator = 'serhiy.storchaka'
    dependencies = ['47042']
    files = []
    hgrepos = []
    issue_num = 40296
    keywords = ['patch']
    message_count = 6.0
    messages = ['366558', '366581', '366609', '415473', '415519', '415554']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'serhiy.storchaka', 'JelleZijlstra', 'miss-islington']
    pr_nums = ['30253', '31976', '31981']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40296'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. serhiy-storchaka commented on Apr 15, 2020

      @serhiy-storchaka
      MemberAuthor
      >>> help(list[int])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/home/serhiy/py/cpython/Lib/_sitebuiltins.py", line 103, in __call__
          return pydoc.help(*args, **kwds)
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1905, in __call__
          self.help(request)
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1964, in help
          else: doc(request, 'Help on %s:', output=self._output)
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1684, in doc
          pager(render_doc(thing, title, forceload))
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1677, in render_doc
          return title % desc + '\n\n' + renderer.document(object, name)
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 381, in document
          if inspect.isclass(object): return self.docclass(*args)
        File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1251, in docclass
          (str(cls.__name__) for cls in type.__subclasses__(object)
      TypeError: descriptor '__subclasses__' for 'type' objects doesn't apply to a 'types.GenericAlias' object
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Apr 15, 2020
    3. serhiy-storchaka commented on Apr 16, 2020

      @serhiy-storchaka
      MemberAuthor

      The problem is that isinstance(list[int], type) returns True, but list[int] is not actually an instance of type.

      >>> isinstance(list[int], type)
      True
      >>> issubclass(type(list[int]), type)
      False
      >>> type.__subclasses__(list[int])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: descriptor '__subclasses__' for 'type' objects doesn't apply to a 'types.GenericAlias' object
    4. gvanrossum commented on Apr 16, 2020

      @gvanrossum
      Member

      Yeah, I think help() or pydoc needs to special-case this. (Didn't your other PR attempt to fix this?)

      Note that issubclass(list[int].__class__, type) returns True -- the __class__ attribute in this case is taken from __origin__, while type() returns the "true" class.

      I don't know what to do about __subclasses__ -- I expect we should just let it be this way.

    5. serhiy-storchaka commented on Mar 18, 2022

      @serhiy-storchaka
      MemberAuthor

      New changeset cd44afc by Serhiy Storchaka in branch 'main':
      bpo-40296: Fix supporting generic aliases in pydoc (GH-30253)
      cd44afc

    6. serhiy-storchaka commented on Mar 18, 2022

      @serhiy-storchaka
      MemberAuthor

      New changeset a5b7678 by Serhiy Storchaka in branch '3.10':
      [3.10] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976)
      a5b7678

    7. serhiy-storchaka commented on Mar 19, 2022

      @serhiy-storchaka
      MemberAuthor

      New changeset e207d72 by Miss Islington (bot) in branch '3.9':
      [3.9] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976) (GH-31981)
      e207d72

    8. 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

      3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard 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