New submission from mike bayer <mike...@zzzcomputing.com>: The constructor for WeakValueDictionary does not obey the contract documented in its comments:
# We inherit the constructor without worrying about the input # dictionary; since it uses our .update() method, we get the right # checks yet it initializes with: self.data = d = {} d.update(*args, **kw) i.e. the "update()" method of dict, so that a dict passed to the constructor initializes non-weakrefed values in the dict which is completely invalid state. Contrast to that of 2.6, which properly uses the superclass: UserDict.UserDict.__init__(self, *args, **kw) A simple test which raises an exception on 3.0.1 is as follows: import weakref class Foo(object): pass mydict = dict((k, Foo()) for k in range(10)) w = weakref.WeakValueDictionary(mydict) assert w[5] ---------- messages: 88577 nosy: zzzeek severity: normal status: open title: WeakValueDictionary constructor ported to Python 3.0 incorrectly versions: Python 3.0 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6149> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com