Whole file
martinblech/xmltodict
The author described this change as “Fix multiroot check for list values”. It counts as a record because the check below fails on the code as it stood at 8bbcd5bfc and passes on 263e6bfd2, with nothing else changed between the two runs.
Projectmartinblech/xmltodict
Fix saved2015-02-04
Sharing licenceMIT · LICENSE
Change size+5 −3
What the code was meant to do, written into the code itself as a save note
Fix multiroot check for list values
The change
| 256 | 256 | preprocessor=None, | |
| 257 | 257 | pretty=False, | |
| 258 | 258 | newl='\n', | |
| 259 | - | indent='\t'): | |
| 259 | + | indent='\t', | |
| 260 | + | full_document=True): | |
| 260 | 261 | if preprocessor is not None: | |
| 261 | 262 | result = preprocessor(key, value) | |
| 262 | 263 | if result is None: | |
| ⋯ | |||
| 264 | 265 | key, value = result | |
| 265 | 266 | if not isinstance(value, (list, tuple)): | |
| 266 | 267 | value = [value] | |
| 267 | - | if depth == 0 and len(value) > 1: | |
| 268 | + | if full_document and depth == 0 and len(value) > 1: | |
| 268 | 269 | raise ValueError('document with multiple roots') | |
| 269 | 270 | for v in value: | |
| 270 | 271 | if v is None: | |
| ⋯ | |||
| 328 | 329 | if full_document: | |
| 329 | 330 | content_handler.startDocument() | |
| 330 | 331 | for key, value in input_dict.items(): | |
| 331 | - | _emit(key, value, content_handler, **kwargs) | |
| 332 | + | _emit(key, value, content_handler, full_document=full_document, | |
| 333 | + | **kwargs) | |
| 332 | 334 | if full_document: | |
| 333 | 335 | content_handler.endDocument() | |
| 334 | 336 | if must_return: | |
The check that tells the two apart
fail→pass·tests/test_dicttoxml.py::DictToXMLTestCase::test_multiple_roots_nofulldoc
Check file tests/test_dicttoxml.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 it8bbcd5bfc6640d44e62a11cc4c9d41a5a4e67d94
Broken version dated2015-01-18
Modulexmltodict
Units changed_emit, unparse
Fingerprint5c03b04850ab2605
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
- 2026-02-15fix(unparse): serialize None text/attrs as empty values (fixes #401)
- 2025-09-17fix: allow DOCTYPE with disable_entities=True (default)
- 2025-09-16fix: fail closed when entities disabled
- 2025-09-16fix: validate XML comments
- 2025-09-12fix(unparse): handle non-string `#text` with attributes; unify value conversion
- 2025-09-12fix(unparse): skip empty lists to keep pretty/compact outputs consistent