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

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

Closed
christopherthemagnificent mannequin opened this issue Dec 11, 2011 · 5 comments
Labels
docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@christopherthemagnificent
Copy link
Mannequin

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']

    @christopherthemagnificent
    Copy link
    Mannequin Author

    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.

    @christopherthemagnificent christopherthemagnificent mannequin added docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Dec 11, 2011
    @amauryfa
    Copy link
    Member

    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__

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 21, 2011

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 21, 2011

    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

    @pitrou
    Copy link
    Member

    pitrou commented Dec 21, 2011

    Now fixed in all 3 branches.

    @pitrou pitrou closed this as completed Dec 21, 2011
    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants