rtyler / py-yajl

py-yajl provides Python bindings for the Yajl JSON encoder/decoder library
http://rtyler.github.com/py-yajl
74 stars 18 forks source link

Raise an exception when objects inside a data structure cannot be processed #9

Closed indigoviolet closed 14 years ago

indigoviolet commented 14 years ago

Oh, sorry to report this separately, but sets have the same issue as #8. In general, it seems like it would be nice to raise an exception when an object inside a list (for example) cannot be processed.

In [2]: yajl.dumps(set([3,4]))

ValueError Traceback (most recent call last) in ()

ValueError: Failed to process

In [3]: yajl.dumps([set([3,4])]) Out[3]: '[]'

(json cannot do this earlier, but raises an exception).

rtyler commented 14 years ago

Another good catch, json.dumps throws a TypeError, so we should probably not be throwing the ValueError there

rtyler commented 14 years ago

This also highlights a bug that already existed, if a list contains an unserializable object yajl.dumps would simply return a '[]' instead of raising the TypeError

rtyler commented 14 years ago

Resolved with SHA: 9d8d1a4dc46df1f9161bcaba9d3da163d9811271

indigoviolet commented 14 years ago

And thanks again!