Avoid mutating a mutable kwarg

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2021-02-23 16:53:21 +00:00
parent 371d627875
commit 449fa9c131
No known key found for this signature in database
GPG key ID: A65B78DBE67C7AAC

View file

@ -2109,7 +2109,7 @@ def removeDefaultAttributeValue(node, attribute):
"""
Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance!
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased performance!
"""
if not node.hasAttribute(attribute.name):
return 0
@ -2134,7 +2134,7 @@ def removeDefaultAttributeValue(node, attribute):
return 0
def removeDefaultAttributeValues(node, options, tainted=set()):
def removeDefaultAttributeValues(node, options, tainted=None):
u"""'tainted' keeps a set of attributes defined in parent nodes.
For such attributes, we don't delete attributes with default values."""
@ -2142,6 +2142,9 @@ def removeDefaultAttributeValues(node, options, tainted=set()):
if node.nodeType != Node.ELEMENT_NODE:
return 0
if tainted is None:
tainted = set()
# Conditionally remove all default attributes defined in 'default_attributes' (a list of 'DefaultAttribute's)
#
# For increased performance do not iterate the whole list for each element but run only on valid subsets