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.

Author andymaier
Recipients andymaier
Date 2014-05-23.17:27:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400866031.36.0.493061688069.issue21561@psf.upfronthosting.co.za>
In-reply-to
Content
Using the enum34 backport of enums, the help() function on an enum class Colors displays only:


-------
Help on class Colors in module __main__:

Colors = <enum 'Colors'>
-------

Source code to reproduce:
-------
from enum import Enum # enum34 package

class Colors(Enum):
    """docstring for enumeration Colors"""
    RED = 1
    GREEN = "2"
    BLUE = [3]

help(Colors)
-------

Versions used:
  python 2.7.6
  enum34 1.0
Platform: Windows 7

I debugged the issue, found the place where it breaks down, and made a fix. However, it may well be that the fix is just a cure to a symptom, and that a better fix is possible.

Here is the fix:
In pydoc.py, class TextDoc, method docclass():
Change this code on line 1220+:
-------
            if thisclass is __builtin__.object:
                attrs = inherited
                continue
            elif thisclass is object:
                tag = "defined here"
            else:
                tag = "inherited from %s" % classname(thisclass,
                                                      object.__module__)
-------
to this, by adding the two lines marked with "added":
-------
            if thisclass is __builtin__.object:
                attrs = inherited
                continue
            elif thisclass is object:
                tag = "defined here"
            elif thisclass is None:            # <-- added
                tag = "inherited from TBD"     # <-- added
            else:
                tag = "inherited from %s" % classname(thisclass,
                                                      object.__module__)
-------

It breaks down during the last round through the 'while attrs' loop, where thisclass is None. I did not investigate why thisclass is None.

Without the fix, this causes an AttributeError to be raised by the classname() function, which then further on causes the dummy documentation to be generated.

With the fix, the help(Colors) output becomes:

-------
Help on class Colors in module __main__:

class Colors(enum.Enum)
 |  docstring for enumeration Colors
 |
 |  Method resolution order:
 |      Colors
 |      enum.Enum
 |      __builtin__.object
 |
 |  Data and other attributes defined here:
 |
 |  BLUE = <Colors.BLUE: [3]>
 |
 |  GREEN = <Colors.GREEN: '2'>
 |
 |  RED = <Colors.RED: 1>
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from TBD:
 |
 |  __members__ = {'BLUE': <Colors.BLUE: [3]>, 'GREEN': <Colors.GREEN: '2'...
-------
History
Date User Action Args
2014-05-23 17:27:11andymaiersetrecipients: + andymaier
2014-05-23 17:27:11andymaiersetmessageid: <1400866031.36.0.493061688069.issue21561@psf.upfronthosting.co.za>
2014-05-23 17:27:11andymaierlinkissue21561 messages
2014-05-23 17:27:10andymaiercreate