New submission from Brandon Zerbe: 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! ---------- messages: 256525 nosy: billyziege priority: normal severity: normal status: open title: inspect.getmro() fails when base class lacks __bases__ attribute. versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25884> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com