[New-bugs-announce] [issue35464] json.dumps very unclear exception

Or report at bugs.python.org
Tue Dec 11 09:52:03 EST 2018


New submission from Or <orshemy at outlook.com>:

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 at 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".

----------
components: Library (Lib)
messages: 331632
nosy: orshemy
priority: normal
severity: normal
status: open
title: json.dumps very unclear exception
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35464>
_______________________________________


More information about the New-bugs-announce mailing list