diff --git a/pandas/_libs/internals.pyx b/pandas/_libs/internals.pyx index 8e61a772912af..ba108c4524b9c 100644 --- a/pandas/_libs/internals.pyx +++ b/pandas/_libs/internals.pyx @@ -1,7 +1,7 @@ import cython from cython import Py_ssize_t -from cpython.object cimport PyObject +from cpython.slice cimport PySlice_GetIndicesEx cdef extern from "Python.h": Py_ssize_t PY_SSIZE_T_MAX @@ -9,13 +9,6 @@ cdef extern from "Python.h": import numpy as np from numpy cimport int64_t -cdef extern from "compat_helper.h": - cdef int slice_get_indices(PyObject* s, Py_ssize_t length, - Py_ssize_t *start, Py_ssize_t *stop, - Py_ssize_t *step, - Py_ssize_t *slicelength) except -1 - - from pandas._libs.algos import ensure_int64 @@ -258,8 +251,8 @@ cpdef Py_ssize_t slice_len( if slc is None: raise TypeError("slc must be slice") - slice_get_indices(slc, objlen, - &start, &stop, &step, &length) + PySlice_GetIndicesEx(slc, objlen, + &start, &stop, &step, &length) return length @@ -278,8 +271,8 @@ cdef slice_get_indices_ex(slice slc, Py_ssize_t objlen=PY_SSIZE_T_MAX): if slc is None: raise TypeError("slc should be a slice") - slice_get_indices(slc, objlen, - &start, &stop, &step, &length) + PySlice_GetIndicesEx(slc, objlen, + &start, &stop, &step, &length) return start, stop, step, length diff --git a/pandas/_libs/src/compat_helper.h b/pandas/_libs/src/compat_helper.h deleted file mode 100644 index 01d5b843d1bb6..0000000000000 --- a/pandas/_libs/src/compat_helper.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2016, PyData Development Team -All rights reserved. - -Distributed under the terms of the BSD Simplified License. - -The full license is in the LICENSE file, distributed with this software. -*/ - -#ifndef PANDAS__LIBS_SRC_COMPAT_HELPER_H_ -#define PANDAS__LIBS_SRC_COMPAT_HELPER_H_ - -#include "Python.h" -#include "inline_helper.h" - -/* -PySlice_GetIndicesEx changes signature in PY3 -but 3.6.1 in particular changes the behavior of this function slightly -https://bugs.python.org/issue27867 - - -In 3.6.1 PySlice_GetIndicesEx was changed to a macro -inadvertently breaking ABI compat. For now, undefing -the macro, which restores compat. -https://github.com/pandas-dev/pandas/issues/15961 -https://bugs.python.org/issue29943 -*/ - -#ifndef PYPY_VERSION -# if PY_VERSION_HEX < 0x03070000 && defined(PySlice_GetIndicesEx) -# undef PySlice_GetIndicesEx -# endif // PY_VERSION_HEX -#endif // PYPY_VERSION - -PANDAS_INLINE int slice_get_indices(PyObject *s, - Py_ssize_t length, - Py_ssize_t *start, - Py_ssize_t *stop, - Py_ssize_t *step, - Py_ssize_t *slicelength) { - return PySlice_GetIndicesEx(s, length, start, stop, - step, slicelength); -} - -#endif // PANDAS__LIBS_SRC_COMPAT_HELPER_H_ diff --git a/setup.py b/setup.py index a7bc7a333cdd6..545765ecb114d 100755 --- a/setup.py +++ b/setup.py @@ -83,10 +83,7 @@ def is_platform_mac(): _pxi_dep_template = { - "algos": [ - "_libs/algos_common_helper.pxi.in", - "_libs/algos_take_helper.pxi.in", - ], + "algos": ["_libs/algos_common_helper.pxi.in", "_libs/algos_take_helper.pxi.in"], "hashtable": [ "_libs/hashtable_class_helper.pxi.in", "_libs/hashtable_func_helper.pxi.in", @@ -544,7 +541,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): ts_include = ["pandas/_libs/tslibs/src", "pandas/_libs/tslibs"] -lib_depends = ["pandas/_libs/src/parse_helper.h", "pandas/_libs/src/compat_helper.h"] +lib_depends = ["pandas/_libs/src/parse_helper.h"] np_datetime_headers = [ "pandas/_libs/tslibs/src/datetime/np_datetime.h", @@ -823,5 +820,5 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): entry_points={ "pandas_plotting_backends": ["matplotlib = pandas:plotting._matplotlib"] }, - **setuptools_kwargs + **setuptools_kwargs, )