summaryrefslogtreecommitdiffstats
path: root/Lib/collections/__init__.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-29 20:37:09 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-29 20:37:09 (GMT)
commitf4ee1c23e8c2981c01bca7a9bcb3904833726c18 (patch)
tree827d7e2f7ba4fc652c80239d18ff0c2ee4423efa /Lib/collections/__init__.py
parent3066fc41d1a054e7734e8334af9758173ee0aa9d (diff)
parent68f5ef226e9b62b1755ee98ae3d35a4aedc56684 (diff)
downloadcpython-f4ee1c23e8c2981c01bca7a9bcb3904833726c18.zip
cpython-f4ee1c23e8c2981c01bca7a9bcb3904833726c18.tar.gz
cpython-f4ee1c23e8c2981c01bca7a9bcb3904833726c18.tar.bz2
Issue #22609: Constructor of collections.UserDict now accepts the self keyword
argument.
Diffstat (limited to 'Lib/collections/__init__.py')
-rw-r--r--Lib/collections/__init__.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 943cbca..e8312a9 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",
+ PendingDeprecationWarning, stacklevel=2)
+ else:
+ dict = None
self.data = {}
if dict is not None:
self.update(dict)