Skip to content

Commit 91522c6

Browse files
committed
BUG: fix improper use of conditional compilation
1 parent df4cffd commit 91522c6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pandas/lib.pyx

+6-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ from cpython cimport (PyDict_New, PyDict_GetItem, PyDict_SetItem,
2626
PyBytes_GET_SIZE,
2727
PyUnicode_GET_SIZE)
2828

29-
try:
30-
from cpython cimport PyString_GET_SIZE
31-
except ImportError:
29+
cdef extern from "Python.h":
30+
int PY_MAJOR_VERSION
31+
32+
if PY_MAJOR_VERSION >= 3:
3233
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE
34+
else:
35+
from cpython cimport PyString_GET_SIZE
3336

3437
cdef extern from "Python.h":
3538
Py_ssize_t PY_SSIZE_T_MAX

0 commit comments

Comments
 (0)