Bug report
Bug description:
Documented behaviour: json.dumps documentation: "Serialize obj to a JSON formatted str." JSONEncoder.iterencode documentation: "Encode the given object, o, and yield each string representation as available." Both describe serialization of the given object.
Expected: Both APIs return '{"a": 1}'.
Actual: json.dumps returns '{"a": 1}', while joined JSONEncoder.iterencode returns '{}'.
import json
class D(dict):
def __bool__(self):
return False
d = D(a=1)
if not all(type(k) is str and type(v) is int for k, v in d.items()):
print("REFUTATION REJECTED: invalid input")
else:
actual = json.dumps(d), ''.join(json.JSONEncoder().iterencode(d))
reference = ''.join(json.JSONEncoder().iterencode(dict(d)))
expected = reference, reference
if actual != expected:
print("REFUTATION CONFIRMED:", d, "actual:", actual, "expected:", expected)
else:
print("REFUTATION REJECTED: both APIs match the dictionary reference")
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library json:
REFUTATION CONFIRMED: {'a': 1} actual: ('{"a": 1}', '{}') expected: ('{"a": 1}', '{"a": 1}')
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/json-20261003-130022-c2
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: json.dumps documentation: "Serialize obj to a JSON formatted str." JSONEncoder.iterencode documentation: "Encode the given object, o, and yield each string representation as available." Both describe serialization of the given object.
Expected: Both APIs return '{"a": 1}'.
Actual: json.dumps returns '{"a": 1}', while joined JSONEncoder.iterencode returns '{}'.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
json: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/json-20261003-130022-c2
CPython versions tested on:
3.14
Operating systems tested on:
Windows