diff --git a/pandas/lib.pyx b/pandas/lib.pyx index 761969491cfc7..e3ee468e1a23b 100644 --- a/pandas/lib.pyx +++ b/pandas/lib.pyx @@ -26,9 +26,9 @@ from cpython cimport (PyDict_New, PyDict_GetItem, PyDict_SetItem, PyBytes_GET_SIZE, PyUnicode_GET_SIZE) -try: +IF PY_MAJOR_VERSION == 2: from cpython cimport PyString_GET_SIZE -except ImportError: +ELSE: from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE cdef extern from "Python.h": diff --git a/pandas/src/hashtable_class_helper.pxi.in b/pandas/src/hashtable_class_helper.pxi.in index b26839599ef38..6bf94c9366c8a 100644 --- a/pandas/src/hashtable_class_helper.pxi.in +++ b/pandas/src/hashtable_class_helper.pxi.in @@ -691,7 +691,11 @@ cdef class PyObjectHashTable(HashTable): def __dealloc__(self): if self.table is not NULL: - self.destroy() + # cython documentation - + # "don’t call any other methods of the object" + # self.destroy() + kh_destroy_pymap(self.table) + self.table = NULL def __len__(self): return self.table.size diff --git a/pandas/src/ujson/python/JSONtoObj.c b/pandas/src/ujson/python/JSONtoObj.c index b0132532c16af..6be4584b854f5 100644 --- a/pandas/src/ujson/python/JSONtoObj.c +++ b/pandas/src/ujson/python/JSONtoObj.c @@ -427,7 +427,11 @@ int Object_npyObjectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) { // only fill label array once, assumes all column labels are the same // for 2-dimensional arrays. +#ifdef PYPY_VERSION + if (PyObject_GET_SIZE(npyarr->labels[labelidx]) <= npyarr->elcount) { +#else if (PyList_GET_SIZE(npyarr->labels[labelidx]) <= npyarr->elcount) { +#endif PyList_Append(npyarr->labels[labelidx], label); } diff --git a/setup.py b/setup.py index 0a84cf527bfb1..015db43afada0 100755 --- a/setup.py +++ b/setup.py @@ -150,6 +150,12 @@ def build_extensions(self): with open(outfile, "w") as f: f.write(pyxcontent) + # used in lib.pyx, assumes old_build_ext + if not self.cython_compile_time_env: + self.cython_compile_time_env = {} + major = sys.version_info.major + self.cython_compile_time_env['PY_MAJOR_VERSION'] = major + numpy_incl = pkg_resources.resource_filename('numpy', 'core/include') for ext in self.extensions: