Message88577
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] |
|
Date |
User |
Action |
Args |
2009-05-30 20:07:44 | zzzeek | set | recipients:
+ zzzeek |
2009-05-30 20:07:44 | zzzeek | set | messageid: <1243714064.27.0.0793186526424.issue6149@psf.upfronthosting.co.za> |
2009-05-30 20:07:41 | zzzeek | link | issue6149 messages |
2009-05-30 20:07:40 | zzzeek | create | |
|