summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2020-10-03 06:41:35 (GMT)
committerGitHub <noreply@github.com>2020-10-03 06:41:35 (GMT)
commita0f2b664335eb689abdecc677e09a193f503af59 (patch)
treea8778c488830bc68830a489395d9cbfa80c16526 /Lib/xml
parentebc8072c3dbcee983db4c709095426b4dc6d0516 (diff)
downloadcpython-a0f2b664335eb689abdecc677e09a193f503af59.zip
cpython-a0f2b664335eb689abdecc677e09a193f503af59.tar.gz
cpython-a0f2b664335eb689abdecc677e09a193f503af59.tar.bz2
bpo-41900: C14N 2.0 serialisation failed for unprefixed attributes when a default namespace was defined. (GH-22474) (GH-22507)
(cherry picked from commit 6a412c94b6b68e7e3632562dc7358a12ffd1447f)
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):