New submission from Andy Maier: 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'... ------- ---------- components: Library (Lib) files: bug1.py messages: 218979 nosy: andymaier priority: normal severity: normal status: open title: help() on enum34 enumeration class creates only a dummy documentation type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file35327/bug1.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21561> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com