From 6a412c94b6b68e7e3632562dc7358a12ffd1447f Mon Sep 17 00:00:00 2001 From: scoder Date: Sat, 3 Oct 2020 08:07:07 +0200 Subject: bpo-41900: C14N 2.0 serialisation failed for unprefixed attributes when a default namespace was defined. (GH-22474) --- Lib/xml/etree/ElementTree.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Lib/xml/etree') diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index da2bcad0b4..7a269001d6 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1876,6 +1876,11 @@ class C14NWriterTarget: self._declared_ns_stack[-1].append((uri, prefix)) return f'{prefix}:{tag}' if prefix else tag, tag, uri + if not uri: + # As soon as a default namespace is defined, + # anything that has no namespace (and thus, no prefix) goes there. + return tag, tag, uri + raise ValueError(f'Namespace "{uri}" is not declared in scope') def data(self, data): -- cgit v1.2.1