Skip to content

Commit 2e3c256

Browse files
committed
BUG: improper use of conditional compilation always resulted in PyUnicode_GET_SIZE
1 parent df4cffd commit 2e3c256

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/lib.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ from cpython cimport (PyDict_New, PyDict_GetItem, PyDict_SetItem,
2626
PyBytes_GET_SIZE,
2727
PyUnicode_GET_SIZE)
2828

29-
try:
29+
IF PY_MAJOR_VERSION == 2:
3030
from cpython cimport PyString_GET_SIZE
31-
except ImportError:
31+
ELSE:
3232
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE
3333

3434
cdef extern from "Python.h":

setup.py

+5
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ def build_extensions(self):
149149

150150
with open(outfile, "w") as f:
151151
f.write(pyxcontent)
152+
# XXX used only in lib.pyx, assumes old_build_ext
153+
if not self.cython_compile_time_env:
154+
self.cython_compile_time_env = {}
155+
major = sys.version_info.major
156+
self.cython_compile_time_env['PY_MAJOR_VERSION'] = major
152157

153158
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
154159

0 commit comments

Comments
 (0)