summaryrefslogtreecommitdiffstats
path: root/Lib/collections
diff options
context:
space:
mode:
authorKamil Turek <kamil.turek@hotmail.com>2021-03-14 03:15:44 (GMT)
committerGitHub <noreply@github.com>2021-03-14 03:15:44 (GMT)
commit9923df96413a0b480a34ec1d537b66ca0eeb0fdc (patch)
tree1612d5da49a8ddf65ec81139a79d548786cfc1ea /Lib/collections
parent9c376bc1c4c8bcddb0bc4196b79ec8c75da494a8 (diff)
downloadcpython-9923df96413a0b480a34ec1d537b66ca0eeb0fdc.zip
cpython-9923df96413a0b480a34ec1d537b66ca0eeb0fdc.tar.gz
cpython-9923df96413a0b480a34ec1d537b66ca0eeb0fdc.tar.bz2
bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788)
Diffstat (limited to 'Lib/collections')
-rw-r--r--Lib/collections/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 6404ea9..89c73bb 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -1010,12 +1010,15 @@ class ChainMap(_collections_abc.MutableMapping):
__copy__ = copy
- def new_child(self, m=None): # like Django's Context.push()
+ def new_child(self, m=None, **kwargs): # like Django's Context.push()
'''New ChainMap with a new map followed by all previous maps.
If no map is provided, an empty dict is used.
+ Keyword arguments update the map or new empty dict.
'''
if m is None:
- m = {}
+ m = kwargs
+ elif kwargs:
+ m.update(kwargs)
return self.__class__(m, *self.maps)
@property