Skip to content

Commit 1cf2260

Browse files
authored
gh-79315: Add Include/cpython/sliceobject.h header (#139729)
1 parent f962e1e commit 1cf2260

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

Include/cpython/sliceobject.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef Py_CPYTHON_SLICEOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
/* Slice object interface */
6+
7+
/*
8+
A slice object containing start, stop, and step data members (the
9+
names are from range). After much talk with Guido, it was decided to
10+
let these be any arbitrary python type. Py_None stands for omitted values.
11+
*/
12+
typedef struct {
13+
PyObject_HEAD
14+
PyObject *start, *stop, *step; /* not NULL */
15+
} PySliceObject;
16+
17+
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
18+
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
19+
PyObject **start_ptr, PyObject **stop_ptr,
20+
PyObject **step_ptr);

Include/sliceobject.h

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,13 @@ PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
1616

1717
/* Slice object interface */
1818

19-
/*
20-
21-
A slice object containing start, stop, and step data members (the
22-
names are from range). After much talk with Guido, it was decided to
23-
let these be any arbitrary python type. Py_None stands for omitted values.
24-
*/
25-
#ifndef Py_LIMITED_API
26-
typedef struct {
27-
PyObject_HEAD
28-
PyObject *start, *stop, *step; /* not NULL */
29-
} PySliceObject;
30-
#endif
31-
3219
PyAPI_DATA(PyTypeObject) PySlice_Type;
3320
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
3421

3522
#define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type)
3623

3724
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
3825
PyObject* step);
39-
#ifndef Py_LIMITED_API
40-
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
41-
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
42-
PyObject **start_ptr, PyObject **stop_ptr,
43-
PyObject **step_ptr);
44-
#endif
4526
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
4627
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
4728
Py_DEPRECATED(3.7)
@@ -63,6 +44,12 @@ PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
6344
Py_ssize_t step);
6445
#endif
6546

47+
#ifndef Py_LIMITED_API
48+
# define Py_CPYTHON_SLICEOBJECT_H
49+
# include "cpython/sliceobject.h"
50+
# undef Py_CPYTHON_SLICEOBJECT_H
51+
#endif
52+
6653
#ifdef __cplusplus
6754
}
6855
#endif

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,7 @@ PYTHON_HEADERS= \
12971297
$(srcdir)/Include/cpython/pythonrun.h \
12981298
$(srcdir)/Include/cpython/pythread.h \
12991299
$(srcdir)/Include/cpython/setobject.h \
1300+
$(srcdir)/Include/cpython/sliceobject.h \
13001301
$(srcdir)/Include/cpython/traceback.h \
13011302
$(srcdir)/Include/cpython/tracemalloc.h \
13021303
$(srcdir)/Include/cpython/tupleobject.h \

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
<ClInclude Include="..\Include\cpython\pythonrun.h" />
192192
<ClInclude Include="..\Include\cpython\pythread.h" />
193193
<ClInclude Include="..\Include\cpython\setobject.h" />
194+
<ClInclude Include="..\Include\cpython\sliceobject.h" />
194195
<ClInclude Include="..\Include\cpython\traceback.h" />
195196
<ClInclude Include="..\Include\cpython\tracemalloc.h" />
196197
<ClInclude Include="..\Include\cpython\tupleobject.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@
492492
<ClInclude Include="..\Include\cpython\tupleobject.h">
493493
<Filter>Include\cpython</Filter>
494494
</ClInclude>
495+
<ClInclude Include="..\Include\cpython\sliceobject.h">
496+
<Filter>Include\cpython</Filter>
497+
</ClInclude>
495498
<ClInclude Include="..\Include\cpython\traceback.h">
496499
<Filter>Include\cpython</Filter>
497500
</ClInclude>

0 commit comments

Comments
 (0)