summaryrefslogtreecommitdiff
path: root/Lib/collections
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2013-01-11 23:39:53 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2013-01-11 23:39:53 +0000
commit34a2132a99b9f54c306d1d249d19303bdf33769f (patch)
tree32a57c8a022daf211414d761ce685a9028bd7485 /Lib/collections
parent1f0b1930a7281407969f7c70eba70a9fc8d31a04 (diff)
downloadcpython-34a2132a99b9f54c306d1d249d19303bdf33769f.tar.gz
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 53083e4bd6..0612e1f610 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()