[New-bugs-announce] [issue1747] isinstance(NotSubclassOfObject, InstanceOfAbcMeta) fails instead of returning False

Jeffrey Yasskin report at bugs.python.org
Sun Jan 6 23:46:35 CET 2008


New submission from Jeffrey Yasskin:

Python 2.6a0 (trunk:59791M, Jan  6 2008, 12:22:37) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import abc
[30620 refs]
>>> class A:
...   __metaclass__ = abc.ABCMeta
... 
[30650 refs]
>>> class B:
...   pass
... 
[30659 refs]
>>> issubclass(B, A)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jyasskin/src/python/trunk-abc/Lib/abc.py", line 191, in
__subclasscheck__
    if cls in subclass.__mro__:
AttributeError: class B has no attribute '__mro__'
[30701 refs]
>>> 


This causes Decimal to break in interesting ways when I make it subclass
numbers.Real. test_abc doesn't catch it because it declares
__metaclass__=type at the top level. :-(

This looks relatively easy to fix, so I'll work on a patch.

----------
assignee: jyasskin
components: Library (Lib)
messages: 59412
nosy: gvanrossum, jyasskin
severity: normal
status: open
title: isinstance(NotSubclassOfObject, InstanceOfAbcMeta) fails instead of returning False
versions: Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1747>
__________________________________


More information about the New-bugs-announce mailing list