Get a reasonable method resolution order of a class and its superclasses for both old-style and new-style classes.
(obj_class)
| 303 | |
| 304 | |
| 305 | def _get_mro(obj_class): |
| 306 | """ Get a reasonable method resolution order of a class and its superclasses |
| 307 | for both old-style and new-style classes. |
| 308 | """ |
| 309 | if not hasattr(obj_class, '__mro__'): |
| 310 | # Old-style class. Mix in object to make a fake new-style class. |
| 311 | try: |
| 312 | obj_class = type(obj_class.__name__, (obj_class, object), {}) |
| 313 | except TypeError: |
| 314 | # Old-style extension type that does not descend from object. |
| 315 | # FIXME: try to construct a more thorough MRO. |
| 316 | mro = [obj_class] |
| 317 | else: |
| 318 | mro = obj_class.__mro__[1:-1] |
| 319 | else: |
| 320 | mro = obj_class.__mro__ |
| 321 | return mro |
| 322 | |
| 323 | |
| 324 | class RepresentationPrinter(PrettyPrinter): |
no outgoing calls
no test coverage detected