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.

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

256256 preprocessor=None,
257257 pretty=False,
258258 newl='\n',
259- indent='\t'):
259+ indent='\t',
260+ full_document=True):
260261 if preprocessor is not None:
261262 result = preprocessor(key, value)
262263 if result is None:
264265 key, value = result
265266 if not isinstance(value, (list, tuple)):
266267 value = [value]
267- if depth == 0 and len(value) > 1:
268+ if full_document and depth == 0 and len(value) > 1:
268269 raise ValueError('document with multiple roots')
269270 for v in value:
270271 if v is None:
328329 if full_document:
329330 content_handler.startDocument()
330331 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)
332334 if full_document:
333335 content_handler.endDocument()
334336 if must_return:

The check that tells the two apart

failpass·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