summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorscoder <stefan_ml@behnel.de>2020-10-03 06:07:07 (GMT)
committerGitHub <noreply@github.com>2020-10-03 06:07:07 (GMT)
commit6a412c94b6b68e7e3632562dc7358a12ffd1447f (patch)
treea88c5e063ff2681ee334dfd92354c69aea3e4e28 /Lib/xml
parentd4b9edd5052a2d9ae3d2be69975cc933afb37737 (diff)
downloadcpython-6a412c94b6b68e7e3632562dc7358a12ffd1447f.zip
cpython-6a412c94b6b68e7e3632562dc7358a12ffd1447f.tar.gz
cpython-6a412c94b6b68e7e3632562dc7358a12ffd1447f.tar.bz2
bpo-41900: C14N 2.0 serialisation failed for unprefixed attributes when a default namespace was defined. (GH-22474)
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementTree.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index da2bcad..7a26900 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):