forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompat_helper.h
50 lines (40 loc) · 1.47 KB
/
compat_helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
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 "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
#endif
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) {
#if PY_VERSION_HEX >= 0x03000000
return PySlice_GetIndicesEx(s, length, start, stop,
step, slicelength);
#else
return PySlice_GetIndicesEx((PySliceObject *)s, length, start,
stop, step, slicelength);
#endif
}
#endif // PANDAS__LIBS_SRC_COMPAT_HELPER_H_