diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 20:51:27 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 20:51:27 (GMT) |
commit | f522bbc9c27d5602b4d0a8287e6f383ba2399f51 (patch) | |
tree | 6be3a09a97313c9d9e78d8ffc1e509e46af68ea9 /Lib/weakref.py | |
parent | cab4566c5a7bda8e26047d439423aa375ca2e317 (diff) | |
download | cpython-f522bbc9c27d5602b4d0a8287e6f383ba2399f51.zip cpython-f522bbc9c27d5602b4d0a8287e6f383ba2399f51.tar.gz cpython-f522bbc9c27d5602b4d0a8287e6f383ba2399f51.tar.bz2 |
Issue #22958: Constructor and update method of weakref.WeakValueDictionary
now accept the self keyword argument.
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r-- | Lib/weakref.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py index 787c885..ca37f87 100644 --- a/Lib/weakref.py +++ b/Lib/weakref.py @@ -44,7 +44,14 @@ class WeakValueDictionary(UserDict.UserDict): # 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[0] + args = args[1:] + 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: @@ -214,7 +221,15 @@ class WeakValueDictionary(UserDict.UserDict): 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[0] + args = args[1:] + 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 |