[New-bugs-announce] [issue5405] There is no way of determining which ABCs a class is registered against

Paul Moore report at bugs.python.org
Mon Mar 2 11:37:02 CET 2009


New submission from Paul Moore <p.f.moore at gmail.com>:

There is no way to determine the list of classes for which issubclass(C,
x) is true. The MRO of the class is fine for normal inheritance, but for
ABCs it is possible to register classes which don't inherit from the
ABC, so that you have a situation where issubclass (C, MyABC) can be
true without MyABC being in C.__mro__:

>>> import abc
>>> class MyABC(object):
...     __metaclass__ = abc.ABCMeta
...
>>> class C(object):
...     pass
...
>>> MyABC.register(C)
>>> issubclass(C, MyABC)
True
>>> C.__mro__
(<class '__main__.C'>, <type 'object'>)
>>>

This means that ABCs do not play well with the type of introspection
required to implement such features as generic functions - namely
enumeration of the (logical) superclasses of a class.

----------
components: Interpreter Core
messages: 83011
nosy: pmoore
priority: normal
severity: normal
status: open
title: There is no way of determining which ABCs a class is registered against
type: behavior
versions: Python 2.7, Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5405>
_______________________________________


More information about the New-bugs-announce mailing list