New submission from Nils Kattenbeck <>:

Instances of weakref.WeakSet are not instances of Set and therefore not of 
MutableSet but they are instances of Collection.
They however implement all required methods for a MutableSet and 
Weak(Key|Value)Dictionary are correctly identified.
Is this just an oversight or am I missing something?

from weakref import WeakKeyDictionary, WeakValueDictionary, WeakSet
from import MutableMapping, Collection, Set, MutableSet

wkdict = WeakKeyDictionary()
wvdict = WeakValueDictionary()
ws = WeakSet()

assert isinstance(wkdict, MutableMapping)
assert isinstance(wvdict, MutableMapping)
assert isinstance(ws, Collection)
assert not isinstance(ws, Set)
assert not isinstance(ws, MutableSet)

components: Library (Lib)
messages: 356326
nosy: Nils Kattenbeck
priority: normal
severity: normal
status: open
title: weakref.WeakSet not instanceof
versions: Python 3.7

Python tracker <>
Python-bugs-list mailing list

Reply via email to