diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-03-21 08:32:01 -0600 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-03-21 15:32:48 +0100 |
commit | ec715b6a26f8280f3ecdabb2e602f5207cdd1eee (patch) | |
tree | b50be7fd26dadafc6006100076817b14c77e5f18 | |
parent | 8bc46f37e55a3e36648ce522afa1f5e0d5f7934d (diff) | |
download | cython-ec715b6a26f8280f3ecdabb2e602f5207cdd1eee.tar.gz |
Add missing declarations to slice.pxd (GH-3411)
PySlice_Unpack() and PySlice_AdjustIndices() were missing from
slice.pxd.
The comments are taken from the C API documentation
(https://docs.python.org/3.8/c-api/slice.html).
-rw-r--r-- | Cython/Includes/cpython/slice.pxd | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Cython/Includes/cpython/slice.pxd b/Cython/Includes/cpython/slice.pxd index 00013754f..202dea716 100644 --- a/Cython/Includes/cpython/slice.pxd +++ b/Cython/Includes/cpython/slice.pxd @@ -45,3 +45,26 @@ cdef extern from "Python.h": # # Changed in version 3.2: The parameter type for the slice parameter was # PySliceObject* before. + + int PySlice_Unpack(object slice, Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step) except -1 + # Extract the start, stop and step data members from a slice object as C + # integers. Silently reduce values larger than PY_SSIZE_T_MAX to + # PY_SSIZE_T_MAX, silently boost the start and stop values less than + # PY_SSIZE_T_MIN to PY_SSIZE_T_MIN, and silently boost the step values + # less than -PY_SSIZE_T_MAX to -PY_SSIZE_T_MAX. + + # Return -1 on error, 0 on success. + + # New in version 3.6.1. + + Py_ssize_t PySlice_AdjustIndices(Py_ssize_t length, Py_ssize_t *start, + Py_ssize_t *stop, Py_ssize_t step) + # Adjust start/end slice indices assuming a sequence of the specified + # length. Out of bounds indices are clipped in a manner consistent with + # the handling of normal slices. + + # Return the length of the slice. Always successful. Doesn’t call Python + # code. + + # New in version 3.6.1. |