summaryrefslogtreecommitdiffstats
path: root/Lib/collections
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2013-01-11 23:39:53 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2013-01-11 23:39:53 (GMT)
commit1ba81ee19a25d52df2d5ce193375086164b1ca77 (patch)
tree6f91d0f4827fa62e35d98c6125f2156b24f552fc /Lib/collections
parent569ff4fbbc4cd0589c369519745d8d17bf3094b0 (diff)
downloadcpython-1ba81ee19a25d52df2d5ce193375086164b1ca77.zip
cpython-1ba81ee19a25d52df2d5ce193375086164b1ca77.tar.gz
cpython-1ba81ee19a25d52df2d5ce193375086164b1ca77.tar.bz2
Closes #16613: Added optional mapping argument to ChainMap.new_child.
Diffstat (limited to 'Lib/collections')
-rw-r--r--Lib/collections/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 53083e4..0612e1f 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -821,9 +821,14 @@ class ChainMap(MutableMapping):
__copy__ = copy
- def new_child(self): # like Django's Context.push()
- 'New ChainMap with a new dict followed by all previous maps.'
- return self.__class__({}, *self.maps)
+ def new_child(self, m=None): # 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.
+ '''
+ if m is None:
+ m = {}
+ return self.__class__(m, *self.maps)
@property
def parents(self): # like Django's Context.pop()