The test case was producing the following error:
Traceback (most recent call last):
File "<stdin>", line 12, in <module>
UnicodeError:
which did not demonstrate the intended difference (this particular
non-json-serializable object DID throw an exception! just not TypeError).
The updated test uses a byte string with all ASCII bytes inside, which
better illustrates the diference.
Signed-off-by: Jeff Epler <jepler@gmail.com>
13 lines
272 B
Python
13 lines
272 B
Python
"""
|
|
categories: Modules,json
|
|
description: JSON module does not throw exception when object is not serialisable
|
|
cause: Unknown
|
|
workaround: Unknown
|
|
"""
|
|
import json
|
|
|
|
try:
|
|
print(json.dumps(b"shouldn't be able to serialise bytes"))
|
|
except TypeError:
|
|
print("TypeError")
|