Skip to content

help() appears to be broken; doesn't display __doc__ for class type when called as help(type) #57790

Closed

Description

@christopherthemagnificent
BPO 13581
Nosy @amauryfa, @pitrou
Superseder
  • bpo-1785: "inspect" gets broken by some descriptors
  • 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 2011-12-21.09:18:54.799>
    created_at = <Date 2011-12-11.18:26:28.407>
    labels = ['interpreter-core', 'type-bug', 'docs']
    title = "help() appears to be broken; doesn't display __doc__ for class type when called as help(type)"
    updated_at = <Date 2011-12-21.09:18:54.797>
    user = 'https://bugs.python.org/christopherthemagnificent'

    bugs.python.org fields:

    activity = <Date 2011-12-21.09:18:54.797>
    actor = 'pitrou'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2011-12-21.09:18:54.799>
    closer = 'pitrou'
    components = ['Documentation', 'Interpreter Core']
    creation = <Date 2011-12-11.18:26:28.407>
    creator = 'christopherthemagnificent'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13581
    keywords = []
    message_count = 5.0
    messages = ['149234', '149241', '149967', '149971', '149972']
    nosy_count = 5.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'christopherthemagnificent', 'docs@python', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '1785'
    type = 'behavior'
    url = 'https://bugs.python.org/issue13581'
    versions = ['Python 3.2']

    Activity

    1. christopherthemagnificent commented on Dec 11, 2011

      christopherthemagnificentmannequin
      MannequinAuthor

      observe help(type) and type.__doc__ in Python 3.1:

      >>> help(type)
      Help on class type in module builtins:
      class type(object)
       |  type(object) -> the object's type
       |  type(name, bases, dict) -> a new type
       |  
       |  Methods defined here:
       |  
       |  __call__(...)
       |      x.__call__(...) <==> x(...)
       |  
       |  __delattr__(...)
       |      x.__delattr__('name') <==> del x.name
       |  
       |  __getattribute__(...)
       |      x.__getattribute__('name') <==> x.name
       |  
       |  __init__(...)
       |      x.__init__(...) initializes x; see x.__class__.__doc__ for signature
       |  
       |  __instancecheck__(...)
       |      __instancecheck__() -> check if an object is an instance
       |  
       |  __repr__(...)
       |      x.__repr__() <==> repr(x)
       |  
       |  __setattr__(...)
       |      x.__setattr__('name', value) <==> x.name = value
       |  
       |  __subclasscheck__(...)
       |      __subclasschck__ -> check if an class is a subclass
       |  
       |  __subclasses__(...)
       |      __subclasses__() -> list of immediate subclasses
       |  
       |  mro(...)
       |      mro() -> list
       |      return a type's method resolution order
       |  
       |  

      | Data descriptors defined here:
      |
      | __abstractmethods__
      |
      | __base__
      |
      | __bases__
      |
      | __basicsize__
      |
      | __dict__
      |
      | __dictoffset__
      |
      | __flags__
      |
      | __itemsize__
      |
      | __mro__
      |
      | __weakrefoffset__
      |
      | ----------------------------------------------------------------------
      | Data and other attributes defined here:
      |
      | __new__ = <built-in method __new__ of type object at 0x145600>
      | T.__new__(S, ...) -> a new object with type S, a subtype of T
      |
      | __prepare__ = <built-in method __prepare__ of type object at 0x145600>
      | __prepare__() -> dict
      | used to create the namespace for the class statement

      >>> type.__doc__
      "type(object) -> the object's type\ntype(name, bases, dict) -> a new type"
      >>> 

      observe help(type) and type.__doc__ in Python 3.2:

      >>> help(type)
      Help on class type in module builtins:
      
      type = <class 'type'>
      >>> type.__doc__
      "type(object) -> the object's type\ntype(name, bases, dict) -> a new type"
      >>> 

      It appears that the __doc__ attribute of <class 'type'> is unchanged from Python 3.1 to 3.2, but it is not being displayed by the help function in Python 3.2.

      The help function is very important to using Python! This should be fixed.

    2. amauryfa commented on Dec 11, 2011

      @amauryfa
      Contributor

      It fails for the same reason as bpo-1785:

      ~/python/cpython3.2$ ./python -c "import inspect; inspect.classify_class_attrs(type)"
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/home/amauryfa/python/cpython3.2/Lib/inspect.py", line 321, in classify_class_attrs
          obj_via_getattr = getattr(cls, name)
      AttributeError: __abstractmethods__
    3. python-dev commented on Dec 21, 2011

      python-devmannequin
      Mannequin

      New changeset 902f694a7b0e by Antoine Pitrou in branch '3.2':
      Issue bpo-1785: Fix inspect and pydoc with misbehaving descriptors.
      http://hg.python.org/cpython/rev/902f694a7b0e

      New changeset b08bf8df8eec by Antoine Pitrou in branch 'default':
      Issue bpo-1785: Fix inspect and pydoc with misbehaving descriptors.
      http://hg.python.org/cpython/rev/b08bf8df8eec

    4. python-dev commented on Dec 21, 2011

      python-devmannequin
      Mannequin

      New changeset 13f56cd8dec1 by Antoine Pitrou in branch '2.7':
      Issue bpo-1785: Fix inspect and pydoc with misbehaving descriptors.
      http://hg.python.org/cpython/rev/13f56cd8dec1

    5. pitrou commented on Dec 21, 2011

      @pitrou
      Member

      Now fixed in all 3 branches.

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

      docsDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions