ENH: add ujson support in pandas.io.json by jreback · Pull Request #3804 · pandas-dev/pandas (original) (raw)

Ok the following patch should make it safe to call Npy_releaseContext multiple times (which is what was causing the problem). Segmentation fault is gone and valgrind output from Python 2.7 debug build is clean. Likewise all tests pass for Python 2.7 and valgrind output for json tests is clean (i.e. there are no warnings for json related code).

diff --git a/pandas/src/ujson/python/JSONtoObj.c b/pandas/src/ujson/python/JSONtoObj.c index 1db7586..160c30f 100644 --- a/pandas/src/ujson/python/JSONtoObj.c +++ b/pandas/src/ujson/python/JSONtoObj.c @@ -10,6 +10,7 @@ typedef struct __PyObjectDecoder JSONObjectDecoder dec;

 void* npyarr;       // Numpy context buffer

@@ -67,9 +68,7 @@ void Npy_releaseContext(NpyArrContext* npyarr) } if (npyarr->dec) {

@@ -88,6 +87,7 @@ JSOBJ Object_npyNewArray(void* _decoder) { // start of array - initialise the context buffer npyarr = decoder->npyarr = PyObject_Malloc(sizeof(NpyArrContext));

@@ -515,7 +515,7 @@ JSOBJ Object_newDouble(double value) static void Object_releaseObject(JSOBJ obj, void* _decoder) { PyObjectDecoder* decoder = (PyObjectDecoder*) _decoder;

@@ -609,6 +610,7 @@ PyObject* JSONToObj(PyObject* self, PyObject *args, PyObject *kwargs)

 if (PyErr_Occurred())
 {