pysimdjson icon indicating copy to clipboard operation
pysimdjson copied to clipboard

Properly populate JSONDecodeError & UnicodeDecodeError

Open TkTech opened this issue 4 years ago • 2 comments

We currently raise a ValueError instead of JSONDecodeError (which is a ValueError subclass) in some cases where JSONDecodeError would be more appropriate. This is because upstream simdjson does not report errors with enough granularity to populate lineno and colno (https://docs.python.org/3/library/json.html#json.JSONDecodeError)

Might be viable to return 0 and 0 for now?

TkTech avatar Jul 20 '20 16:07 TkTech

Please ping issue https://github.com/simdjson/simdjson/issues/237

This is not a fundamental limitation and it is simply a matter of doing the coding.

lemire avatar Jul 20 '20 17:07 lemire

We have the same issue with UnicodeDecodeError here https://github.com/TkTech/pysimdjson/blob/master/simdjson/binding.cpp#L227. However, very few projects I could find seem to care about the additional properties, and those that do use the error in such a way that they would just see a blank string rather than a crash.

TkTech avatar Aug 10 '20 18:08 TkTech