bpo-36431: Use PEP 448 dict unpacking for merging two dicts. (GH-12553)

This commit is contained in:
Serhiy Storchaka 2019-03-27 08:02:28 +02:00 committed by GitHub
parent 384b81d923
commit da0847048a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 29 deletions

View file

@ -169,10 +169,8 @@ class Element:
if not isinstance(attrib, dict):
raise TypeError("attrib must be dict, not %s" % (
attrib.__class__.__name__,))
attrib = attrib.copy()
attrib.update(extra)
self.tag = tag
self.attrib = attrib
self.attrib = {**attrib, **extra}
self._children = []
def __repr__(self):
@ -451,8 +449,7 @@ def SubElement(parent, tag, attrib={}, **extra):
additional attributes given as keyword arguments.
"""
attrib = attrib.copy()
attrib.update(extra)
attrib = {**attrib, **extra}
element = parent.makeelement(tag, attrib)
parent.append(element)
return element

View file

@ -56,8 +56,7 @@ def quoteattr(data, entities={}):
the optional entities parameter. The keys and values must all be
strings; each key will be replaced with its corresponding value.
"""
entities = entities.copy()
entities.update({'\n': '
', '\r': '
', '\t':'	'})
entities = {**entities, '\n': '
', '\r': '
', '\t':'	'}
data = escape(data, entities)
if '"' in data:
if "'" in data: