New submission from miscjunk:

When json.dumps() is called on a numpy.bool_ object, it crashes.

To recreate:
import numpy as np
import json
a = np.array([1,2,3,4,5,6])
a = a < 5
json.dumps(a) #crash
json.dumps(a[0]) #crash
json.dumps(a.tolist()) #this works!

Example of error output
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "..\python-3.3.2.amd64\lib\json\__init__.py", line 236, in dumps
    return _default_encoder.encode(obj)
  File "..\python-3.3.2.amd64\lib\json\encoder.py", line 191, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "..\python-3.3.2.amd64\lib\json\encoder.py", line 249, in iterencode
    return _iterencode(o, 0)
  File "..\python-3.3.2.amd64\lib\json\encoder.py", line 173, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: False is not JSON serializable

----------
components: Extension Modules, Library (Lib)
messages: 191887
nosy: miscjunk
priority: normal
severity: normal
status: open
title: json.dumps() claims numpy.bool_ is not serializable
type: crash
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18303>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to