[New-bugs-announce] [issue10569] abc: `issubclass([], my_abstract_type)` raises exception

Ram Rachum report at bugs.python.org
Sun Nov 28 22:47:59 CET 2010

New submission from Ram Rachum <cool-rr at cool-rr.com>:

>>> import abc
>>> class A(object, metaclass=abc.ABCMeta):
...     pass
>>> issubclass([], A)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    issubclass([], A)
  File "c:\Python32\lib\abc.py", line 137, in __subclasscheck__
    if subclass in cls._abc_cache:
  File "c:\Python32\lib\_weakrefset.py", line 69, in __contains__
    return ref(item) in self.data
TypeError: cannot create weak reference to 'list' object

I should be able to check whether an object is a subclass of something without confirming it's a type first. I think this call should just return False.

components: Library (Lib)
messages: 122736
nosy: cool-RR
priority: normal
severity: normal
status: open
title: abc: `issubclass([], my_abstract_type)` raises exception
type: behavior
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list