Skip to content

Commit be7c4c0

Browse files
committed
Merge pull request #5334 from jtratner/try-fix-for-initobjtojson
CLN: Fix return type for initObjToJSON()
2 parents 142d184 + 6ec26a1 commit be7c4c0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ Bug Fixes
640640
- Bug when trying to display an embedded PandasObject (:issue:`5324`)
641641
- Allows operating of Timestamps to return a datetime if the result is out-of-bounds
642642
related (:issue:`5312`)
643+
- Fix return value/type signature of ``initObjToJSON()`` to be compatible
644+
with numpy's ``import_array()`` (:issue:`5334`, :issue:`5326`)
643645

644646
pandas 0.12.0
645647
-------------

pandas/src/ujson/python/objToJSON.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ enum PANDAS_FORMAT
145145
//#define PRINTMARK() fprintf(stderr, "%s: MARK(%d)\n", __FILE__, __LINE__)
146146
#define PRINTMARK()
147147

148-
#if (PY_VERSION_HEX < 0x03000000)
149-
void initObjToJSON(void)
148+
// import_array() compat
149+
#if (PY_VERSION_HEX >= 0x03000000)
150+
void *initObjToJSON(void)
150151
#else
151-
int initObjToJSON(void)
152+
void initObjToJSON(void)
152153
#endif
153154
{
154155
PyObject *mod_pandas;
@@ -176,8 +177,9 @@ int initObjToJSON(void)
176177
Py_DECREF(mod_tslib);
177178
}
178179

179-
/* Initialise numpy API */
180+
/* Initialise numpy API and use 2/3 compatible return */
180181
import_array();
182+
return NUMPY_IMPORT_ARRAY_RETVAL;
181183
}
182184

183185
static void *PyIntToINT32(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)

0 commit comments

Comments
 (0)