Whole file

martinblech/xmltodict

The author described this change as fix(namespaces): attach `@xmlns` to declaring element when process_namespaces=True. It counts as a record because the check below fails on the code as it stood at 75a17701d and passes on f0322e578, with nothing else changed between the two runs.

Fix saved2025-09-12
Sharing licenceMIT · LICENSE
Change size+3 1

What the code was meant to do, written into the code itself as a save note

fix(namespaces): attach `@xmlns` to declaring element when process_namespaces=True

The change

8585 def startElement(self, full_name, attrs):
8686 name = self._build_name(full_name)
8787 attrs = self._attrs_to_dict(attrs)
88- if attrs and self.namespace_declarations:
88+ if self.namespace_declarations:
89+ if not attrs:
90+ attrs = self.dict_constructor()
8991 attrs['xmlns'] = self.namespace_declarations
9092 self.namespace_declarations = self.dict_constructor()
9193 self.path.append((name, attrs or None))

The check that tells the two apart

failpass·tests/test_xmltodict.py::XMLToDictTestCase::test_namespace_on_root_without_other_attrs

Check file tests/test_xmltodict.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it75a17701db20d5d3ec2ea1f6c901cf2211011eb5
Broken version dated2025-09-08
Modulexmltodict
Units changed_DictSAXHandler
Fingerprint728a0b23b6be471c
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in martinblech/xmltodict