bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788)

This commit is contained in:
Kamil Turek 2021-03-14 04:15:44 +01:00 committed by GitHub
parent 9c376bc1c4
commit 9923df9641
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View file

@ -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