diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-03-27 06:02:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-27 06:02:28 (GMT) |
commit | da0847048aa7f934573fa449cea8643def056aa5 (patch) | |
tree | ab70f219c1e98984908b04a175ced3a155df7036 /Lib/xml | |
parent | 384b81d923addd52125e94470b11d2574ca266a9 (diff) | |
download | cpython-da0847048aa7f934573fa449cea8643def056aa5.zip cpython-da0847048aa7f934573fa449cea8643def056aa5.tar.gz cpython-da0847048aa7f934573fa449cea8643def056aa5.tar.bz2 |
bpo-36431: Use PEP 448 dict unpacking for merging two dicts. (GH-12553)
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 7 | ||||
-rw-r--r-- | Lib/xml/sax/saxutils.py | 3 |
2 files changed, 3 insertions, 7 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index c1cf483..b5ad8e1 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -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 diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index a69c7f7..b4fc2da 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -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: |