This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json.dumps very unclear exception
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: orshemy, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-12-11 14:52 by orshemy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg331632 - (view) Author: Or (orshemy) Date: 2018-12-11 14:52
when dumping a value coming from numpy.random.choice([True,False]) the exception raised is very unclear.

json.dumps(result)

  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")

which prints "True is not JSON serializable" - but it should actually print "<type 'numpy.bool_'> is not JSON serializable".
msg331633 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-11 15:21
This was changed in 3.6 (issue26623). Upgrade to 3.6+ for better error messages.
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79645
2018-12-11 15:21:12serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg331633

resolution: out of date
stage: resolved
2018-12-11 14:52:03orshemycreate