From 9e3598bfb38644ce6a4d6d91c27a1d542c23e900 Mon Sep 17 00:00:00 2001 From: Martin Hammarstedt Date: Mon, 20 May 2024 14:14:29 +0200 Subject: [PATCH] Fix crash when removing namespaces from attributes in xml_import:parse --- CHANGELOG.md | 1 + sparv/modules/xml_import/xml_import.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de7b67dc..453948b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Fixed Stanza which was broken for English. - SweNER no longer hangs on (extremely) long tokens. - Fixed config validation for `korp.context` and `korp.within`. +- Fixed crash when removing namespaces from attributes in `xml_import:parse`. ## [5.2.0] - 2023-12-07 diff --git a/sparv/modules/xml_import/xml_import.py b/sparv/modules/xml_import/xml_import.py index e526225e..6fe89517 100644 --- a/sparv/modules/xml_import/xml_import.py +++ b/sparv/modules/xml_import/xml_import.py @@ -342,7 +342,7 @@ def remove_namespaces(element: etree.Element): uri, _ = get_namespace(element.tag) if uri: element.tag = element.tag[len("{" + uri + "}"):] - for k in element.attrib.keys(): + for k in element.attrib.copy(): uri, _ = get_namespace(k) if uri: element.set(k[len("{" + uri + "}"):], element.attrib[k])