diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 23:38:34 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 23:38:34 +0300 |
commit | 5527cf119dbed1fcd1194712e776ad2bc485eb0d (patch) | |
tree | c801c295fe19c6f3fd2d12236b89b6c7d834d767 /Lib/collections | |
parent | 87b93fe36f3d66bb200c8c0227a4cc7d50ff32d9 (diff) | |
parent | f4ee1c23e8c2981c01bca7a9bcb3904833726c18 (diff) | |
download | cpython-git-5527cf119dbed1fcd1194712e776ad2bc485eb0d.tar.gz |
Issue #22609: Constructor of collections.UserDict now accepts the self keyword
argument.
Diffstat (limited to 'Lib/collections')
-rw-r--r-- | Lib/collections/__init__.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 943cbca4a7..638a4ca1eb 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -939,7 +939,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", + DeprecationWarning, stacklevel=2) + else: + dict = None self.data = {} if dict is not None: self.update(dict) |