Issue 13581: help() appears to be broken; doesn't display doc for class type when called as help(type) (original) (raw)

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.

It fails for the same reason as :

~/python/cpython3.2$ ./python -c "import inspect; inspect.classify_class_attrs(type)" Traceback (most recent call last): File "", line 1, in File "/home/amauryfa/python/cpython3.2/Lib/inspect.py", line 321, in classify_class_attrs obj_via_getattr = getattr(cls, name) AttributeError: abstractmethods