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 billyziege
Recipients billyziege
Date 2015-12-16.15:31:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1450279916.96.0.180877215544.issue25884@psf.upfronthosting.co.za>
In-reply-to
Content
I am using a possibly non-standard python package called Forthon, and when I inspect an object that is dependent on the Forthon class, I get the following error:

  File "/Users/zerbeb/homemade_programs/config2class/src/method_parsing.py", line 18, in get_all_init_args
    inherited_classes = inspect.getmro(class_obj)  
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 346, in getmro
    if hasattr(cls, "__bases__"):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 337, in _searchbases
    for base in cls.__bases__:
AttributeError: 'Forthon' object has no attribute '__bases__'

This was easy enough to fix, simply add "if not hasattr(cls,'__bases__'): return" to the _searchbases function:

def _searchbases(cls, accum):
    # Simulate the "classic class" search order.
    if cls in accum:
        return
    if not hasattr(cls, "__bases__"): #Additional code.
        return
    accum.append(cls)
    for base in cls.__bases__:
        _searchbases(base, accum)

Maybe you have a better solution, but I think this edge case can be trivially solved however you decide to edit the code.

Thanks!
History
Date User Action Args
2015-12-16 15:31:56billyziegesetrecipients: + billyziege
2015-12-16 15:31:56billyziegesetmessageid: <1450279916.96.0.180877215544.issue25884@psf.upfronthosting.co.za>
2015-12-16 15:31:56billyziegelinkissue25884 messages
2015-12-16 15:31:56billyziegecreate