You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue porting a project to Python 3, where simplejson raises a TypeError because of dict_keys:
File "/Users/marca/dev/git-repos/cornice/.tox/py33/lib/python3.3/site-packages/simplejson/encoder.py", line 226, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: dict_keys([1, 2]) is not JSON serializable
This is easily fixed in the project by wrapping the dict_keys with list and that's fine, but I wonder if it makes sense to do it in simplejson as a convenience to make porting to Python 3 easier.
I could submit a PR if this is deemed useful, but I wanted to check first and make sure that this makes sense, wouldn't hurt performance too much, etc.
The text was updated successfully, but these errors were encountered:
Not sure this makes sense, it's the first time that this has come up.
I'd prefer not to add special cases for things like this unless there really was a lot of demand for it. Types like this are pretty opaque and it's hard to test for them.
The encoding of dicts happens via iteration AFAIK, so is this a case where @msabramo, @boriza the code in question explicitly tries to encode the result of some_dict.keys(), rather than encoding some_dict?
I ran into an issue porting a project to Python 3, where simplejson raises a
TypeError
because ofdict_keys
:This is easily fixed in the project by wrapping the
dict_keys
withlist
and that's fine, but I wonder if it makes sense to do it in simplejson as a convenience to make porting to Python 3 easier.I could submit a PR if this is deemed useful, but I wanted to check first and make sure that this makes sense, wouldn't hurt performance too much, etc.
The text was updated successfully, but these errors were encountered: