New submission from Madison May: Currently the json lib only logs the string representation of the variable, which does not always include type information.
I recently ran into a difficult to debug issue with code similar to the following: ``` import json import numpy as np d = {'data': np.int16(5)} json.dumps(d) ``` which produces the following error: ``` TypeError: 5 is not JSON serializable ``` It took us quite a while to determine that `5` was actually of type `np.int` instead of the native type. A cursory glance at StackOverflow suggests that I'm not alone in running into this issue: http://stackoverflow.com/questions/10872604/json-dump-throwing-typeerror-is-not-json-serializable-on-seemingly-vali I'd like to consider modifying the error message to be more similar to the following: ``` TypeError: 5 of type `numpy.int16` is not JSON serializable ``` ---------- components: Library (Lib) messages: 246776 nosy: Madison May priority: normal severity: normal status: open title: Log type of unserializable value when raising JSON TypeError versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24641> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com