mirror of https://github.com/python/cpython
Issue #6149: Fix initialization of WeakValueDictionary objects from non-empty parameters.
This commit is contained in:
parent
3b1b8072f5
commit
c06de477a3
|
@ -942,6 +942,17 @@ class MappingTestCase(TestBase):
|
||||||
dict[o] = o.arg
|
dict[o] = o.arg
|
||||||
return dict, objects
|
return dict, objects
|
||||||
|
|
||||||
|
def test_make_weak_valued_dict_from_dict(self):
|
||||||
|
o = Object(3)
|
||||||
|
dict = weakref.WeakValueDictionary({364:o})
|
||||||
|
self.assertEqual(dict[364], o)
|
||||||
|
|
||||||
|
def test_make_weak_valued_dict_from_weak_valued_dict(self):
|
||||||
|
o = Object(3)
|
||||||
|
dict = weakref.WeakValueDictionary({364:o})
|
||||||
|
dict2 = weakref.WeakValueDictionary(dict)
|
||||||
|
self.assertEqual(dict[364], o)
|
||||||
|
|
||||||
def make_weak_valued_dict(self):
|
def make_weak_valued_dict(self):
|
||||||
dict = weakref.WeakValueDictionary()
|
dict = weakref.WeakValueDictionary()
|
||||||
objects = list(map(Object, range(self.COUNT)))
|
objects = list(map(Object, range(self.COUNT)))
|
||||||
|
|
|
@ -49,7 +49,7 @@ class WeakValueDictionary(collections.MutableMapping):
|
||||||
del self.data[wr.key]
|
del self.data[wr.key]
|
||||||
self._remove = remove
|
self._remove = remove
|
||||||
self.data = d = {}
|
self.data = d = {}
|
||||||
d.update(*args, **kw)
|
self.update(*args, **kw)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
o = self.data[key]()
|
o = self.data[key]()
|
||||||
|
|
|
@ -15,6 +15,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #6149: Fix initialization of WeakValueDictionary objects from non-empty
|
||||||
|
parameters.
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 3.1 release candidate 1?
|
What's New in Python 3.1 release candidate 1?
|
||||||
=============================================
|
=============================================
|
||||||
|
|
Loading…
Reference in New Issue