From fbf0c06e845b585f6ee3bfe5a7470772ab7d86d3 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Tue, 23 Feb 2021 16:53:21 +0000 Subject: [PATCH] Avoid mutating a mutable kwarg Signed-off-by: Niels Thykier --- scour/scour.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scour/scour.py b/scour/scour.py index 9e45a2d..91326c6 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -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