summaryrefslogtreecommitdiffstats
path: root/Lib/weakref.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-29 20:52:09 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-29 20:52:09 (GMT)
commitb5102e3550a589084bf33fae15bf131f47d51b0b (patch)
tree67a2d7be18a1517412cf2fc6d9e5b397fb6eccfc /Lib/weakref.py
parent68f5ef226e9b62b1755ee98ae3d35a4aedc56684 (diff)
downloadcpython-b5102e3550a589084bf33fae15bf131f47d51b0b.zip
cpython-b5102e3550a589084bf33fae15bf131f47d51b0b.tar.gz
cpython-b5102e3550a589084bf33fae15bf131f47d51b0b.tar.bz2
Issue #22958: Constructor and update method of weakref.WeakValueDictionary
now accept the self and the dict keyword arguments.
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r--Lib/weakref.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 12bf975..5d09497 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -98,7 +98,13 @@ class WeakValueDictionary(collections.MutableMapping):
# objects are unwrapped on the way out, and we always wrap on the
# way in).
- def __init__(self, *args, **kw):
+ def __init__(*args, **kw):
+ if not args:
+ raise TypeError("descriptor '__init__' of 'WeakValueDictionary' "
+ "object needs an argument")
+ self, *args = args
+ if len(args) > 1:
+ raise TypeError('expected at most 1 arguments, got %d' % len(args))
def remove(wr, selfref=ref(self)):
self = selfref()
if self is not None:
@@ -252,7 +258,14 @@ class WeakValueDictionary(collections.MutableMapping):
else:
return wr()
- def update(self, dict=None, **kwargs):
+ def update(*args, **kwargs):
+ if not args:
+ raise TypeError("descriptor 'update' of 'WeakValueDictionary' "
+ "object needs an argument")
+ self, *args = args
+ if len(args) > 1:
+ raise TypeError('expected at most 1 arguments, got %d' % len(args))
+ dict = args[0] if args else None
if self._pending_removals:
self._commit_removals()
d = self.data