This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: help() appears to be broken; doesn't display __doc__ for class type when called as help(type)
Type: behavior Stage: resolved
Components: Documentation, Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder: "inspect" gets broken by some descriptors
View: 1785
Assigned To: docs@python Nosy List: amaury.forgeotdarc, christopherthemagnificent, docs@python, pitrou, python-dev
Priority: normal Keywords:

Created on 2011-12-11 18:26 by christopherthemagnificent, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg149234 - (view) Author: Christopher the Magnificent (christopherthemagnificent) Date: 2011-12-11 18:26
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.
msg149241 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-12-11 19:21
It fails for the same reason as issue1785:

~/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__
msg149967 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-12-21 09:01
New changeset 902f694a7b0e by Antoine Pitrou in branch '3.2':
Issue #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 #1785: Fix inspect and pydoc with misbehaving descriptors.
http://hg.python.org/cpython/rev/b08bf8df8eec
msg149971 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-12-21 09:18
New changeset 13f56cd8dec1 by Antoine Pitrou in branch '2.7':
Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
http://hg.python.org/cpython/rev/13f56cd8dec1
msg149972 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-12-21 09:18
Now fixed in all 3 branches.
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57790
2011-12-21 09:18:54pitrousetstatus: open -> closed

superseder: "inspect" gets broken by some descriptors

nosy: + pitrou
messages: + msg149972
resolution: fixed
stage: resolved
2011-12-21 09:18:05python-devsetmessages: + msg149971
2011-12-21 09:01:09python-devsetnosy: + python-dev
messages: + msg149967
2011-12-11 19:21:58amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg149241
2011-12-11 18:26:28christopherthemagnificentcreate