mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #22609: Constructor of collections.UserDict now accepts the self keyword
argument.
This commit is contained in:
parent
e060619d4b
commit
68f5ef226e
3 changed files with 45 additions and 2 deletions
|
@ -883,7 +883,22 @@ class ChainMap(MutableMapping):
|
|||
class UserDict(MutableMapping):
|
||||
|
||||
# Start by filling-out the abstract methods
|
||||
def __init__(self, dict=None, **kwargs):
|
||||
def __init__(*args, **kwargs):
|
||||
if not args:
|
||||
raise TypeError("descriptor '__init__' of 'UserDict' object "
|
||||
"needs an argument")
|
||||
self, *args = args
|
||||
if len(args) > 1:
|
||||
raise TypeError('expected at most 1 arguments, got %d' % len(args))
|
||||
if args:
|
||||
dict = args[0]
|
||||
elif 'dict' in kwargs:
|
||||
dict = kwargs.pop('dict')
|
||||
import warnings
|
||||
warnings.warn("Passing 'dict' as keyword argument is deprecated",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
else:
|
||||
dict = None
|
||||
self.data = {}
|
||||
if dict is not None:
|
||||
self.update(dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue