https://github.com/python/cpython/commit/1cf22600f10322d77ab2c2bb41acabf2360f84e9
commit: 1cf22600f10322d77ab2c2bb41acabf2360f84e9
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-10-08T00:48:18+02:00
summary:
gh-79315: Add Include/cpython/sliceobject.h header (#139729)
files:
A Include/cpython/sliceobject.h
M Include/sliceobject.h
M Makefile.pre.in
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters
diff --git a/Include/cpython/sliceobject.h b/Include/cpython/sliceobject.h
new file mode 100644
index 00000000000000..4c3ea1facebc4e
--- /dev/null
+++ b/Include/cpython/sliceobject.h
@@ -0,0 +1,20 @@
+#ifndef Py_CPYTHON_SLICEOBJECT_H
+# error "this header file must not be included directly"
+#endif
+
+/* 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.
+*/
+typedef struct {
+ PyObject_HEAD
+ PyObject *start, *stop, *step; /* not NULL */
+} PySliceObject;
+
+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);
diff --git a/Include/sliceobject.h b/Include/sliceobject.h
index 35e2ea254ca80a..00c70a6e911b41 100644
--- a/Include/sliceobject.h
+++ b/Include/sliceobject.h
@@ -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
diff --git a/Makefile.pre.in b/Makefile.pre.in
index ff9a84e4c274c4..a356ac0ea943b2 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1297,6 +1297,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/pythonrun.h \
$(srcdir)/Include/cpython/pythread.h \
$(srcdir)/Include/cpython/setobject.h \
+ $(srcdir)/Include/cpython/sliceobject.h \
$(srcdir)/Include/cpython/traceback.h \
$(srcdir)/Include/cpython/tracemalloc.h \
$(srcdir)/Include/cpython/tupleobject.h \
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index d043d23eed85c7..25a7313eb26426 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -191,6 +191,7 @@
<ClInclude Include="..\Include\cpython\pythonrun.h" />
<ClInclude Include="..\Include\cpython\pythread.h" />
<ClInclude Include="..\Include\cpython\setobject.h" />
+ <ClInclude Include="..\Include\cpython\sliceobject.h" />
<ClInclude Include="..\Include\cpython\traceback.h" />
<ClInclude Include="..\Include\cpython\tracemalloc.h" />
<ClInclude Include="..\Include\cpython\tupleobject.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters
b/PCbuild/pythoncore.vcxproj.filters
index 1868b222f18534..edbd88d930a432 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -492,6 +492,9 @@
<ClInclude Include="..\Include\cpython\tupleobject.h">
<Filter>Include\cpython</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\cpython\sliceobject.h">
+ <Filter>Include\cpython</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\cpython\traceback.h">
<Filter>Include\cpython</Filter>
</ClInclude>
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]