Message256525
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! |
|
Date |
User |
Action |
Args |
2015-12-16 15:31:56 | billyziege | set | recipients:
+ billyziege |
2015-12-16 15:31:56 | billyziege | set | messageid: <1450279916.96.0.180877215544.issue25884@psf.upfronthosting.co.za> |
2015-12-16 15:31:56 | billyziege | link | issue25884 messages |
2015-12-16 15:31:56 | billyziege | create | |
|