bpo-41900: C14N 2.0 serialisation failed for unprefixed attributes wh… · python/cpython@6a412c9 · GitHub
Skip to content

Commit 6a412c9

Browse files
authored
bpo-41900: C14N 2.0 serialisation failed for unprefixed attributes when a default namespace was defined. (GH-22474)
1 parent d4b9edd commit 6a412c9

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lib/test/test_xml_etree.py

Lines changed: 8 additions & 0 deletions

Lib/xml/etree/ElementTree.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,11 @@ def _qname(self, qname, uri=None):
18761876
self._declared_ns_stack[-1].append((uri, prefix))
18771877
return f'{prefix}:{tag}' if prefix else tag, tag, uri
18781878

1879+
if not uri:
1880+
# As soon as a default namespace is defined,
1881+
# anything that has no namespace (and thus, no prefix) goes there.
1882+
return tag, tag, uri
1883+
18791884
raise ValueError(f'Namespace "{uri}" is not declared in scope')
18801885

18811886
def data(self, data):
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)