Bug report
Bug description:
Documented behaviour: Python plistlib documentation, load(): "The dict_type is the type of the dictionaries that are returned (by default, dict)."
Expected: Return a collections.UserDict containing {'a': 'b'}.
Actual: Raises ValueError: unexpected key at line 5.
import plistlib
from io import BytesIO
from collections import UserDict
data = {'a': 'b'}
try:
if not data or not all(isinstance(k, str) and isinstance(v, str)
for k, v in data.items()):
raise ValueError("input is not a nonempty string-to-string dictionary")
xml = plistlib.dumps(data, fmt=plistlib.FMT_XML)
if plistlib.load(BytesIO(xml)) != data:
raise ValueError("XML does not represent the reported input")
except Exception as e:
print("REFUTATION REJECTED:", "invalid input:", repr(e))
else:
expected = UserDict(data)
try:
actual = plistlib.load(BytesIO(xml), dict_type=UserDict)
broken = not isinstance(actual, UserDict) or actual != expected
except Exception as e:
actual = ("exception", type(e).__name__, str(e))
broken = True
if broken:
print("REFUTATION CONFIRMED:", "input:", data,
"actual:", repr(actual), "expected:", repr(expected))
else:
print("REFUTATION REJECTED:", "returned the expected UserDict")
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library plistlib:
REFUTATION CONFIRMED: input: {'a': 'b'} actual: ('exception', 'ValueError', 'unexpected key at line 5') expected: {'a': 'b'}
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/plistlib-20261003-042133-c2
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: Python plistlib documentation, load(): "The dict_type is the type of the dictionaries that are returned (by default, dict)."
Expected: Return a collections.UserDict containing {'a': 'b'}.
Actual: Raises ValueError: unexpected key at line 5.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
plistlib:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/plistlib-20261003-042133-c2
CPython versions tested on:
3.14
Operating systems tested on:
Windows