gh-79315: Add Include/cpython/sliceobject.h header (#139729)

This commit is contained in:
Victor Stinner 2025-10-08 00:48:18 +02:00 committed by GitHub
parent f962e1eacf
commit 1cf22600f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 19 deletions

View file

@ -16,19 +16,6 @@ PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
/* Slice object interface */
/*
A slice object containing start, stop, and step data members (the
names are from range). After much talk with Guido, it was decided to
let these be any arbitrary python type. Py_None stands for omitted values.
*/
#ifndef Py_LIMITED_API
typedef struct {
PyObject_HEAD
PyObject *start, *stop, *step; /* not NULL */
} PySliceObject;
#endif
PyAPI_DATA(PyTypeObject) PySlice_Type;
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
@ -36,12 +23,6 @@ PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
PyObject **start_ptr, PyObject **stop_ptr,
PyObject **step_ptr);
#endif
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
Py_DEPRECATED(3.7)
@ -63,6 +44,12 @@ PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
Py_ssize_t step);
#endif
#ifndef Py_LIMITED_API
# define Py_CPYTHON_SLICEOBJECT_H
# include "cpython/sliceobject.h"
# undef Py_CPYTHON_SLICEOBJECT_H
#endif
#ifdef __cplusplus
}
#endif