-
-
Notifications
You must be signed in to change notification settings - Fork 36.9k
gh-158077: Remove deprecated PySlice_GetIndicesEx() function #158089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,23 +25,28 @@ PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, | |
| PyObject* step); | ||
| 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) | ||
| PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length, | ||
| Py_ssize_t *start, Py_ssize_t *stop, | ||
| Py_ssize_t *step, | ||
| Py_ssize_t *slicelength); | ||
|
|
||
| #if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that Python 3.16 should both with limited C API 3.5.x. Use Python 3.16 to target the recent stable ABI. Or use an old Python version to target an old stable ABI version. I prefer to remove
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Python 3.6 is no longer supported upstream, we may even simplify the check as |
||
| #define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \ | ||
| PySlice_Unpack((slice), (start), (stop), (step)) < 0 ? \ | ||
| ((*(slicelen) = 0), -1) : \ | ||
| ((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \ | ||
| 0)) | ||
|
|
||
| #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060100 | ||
| PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice, | ||
| Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); | ||
| PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length, | ||
| Py_ssize_t *start, Py_ssize_t *stop, | ||
| Py_ssize_t step); | ||
|
|
||
| static inline int | ||
| _PySlice_GetIndicesEx(PyObject *slice, Py_ssize_t length, | ||
| Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, | ||
| Py_ssize_t *slicelen) | ||
| { | ||
| if (PySlice_Unpack(slice, start, stop, step) < 0) { | ||
| *slicelen = 0; | ||
| return -1; | ||
| } | ||
|
|
||
| *slicelen = PySlice_AdjustIndices(length, start, stop, *step); | ||
| return 0; | ||
| } | ||
| #define PySlice_GetIndicesEx _PySlice_GetIndicesEx | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The static inline function should have a different name, so sliceobject.c can implement a function under "PySlice_GetIndicesEx" name.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. The point of the macro is that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah? It wasn't obvious to me at all when I read the macro. Also, it seems like PySlice_GetIndicesEx() is not tested. |
||
| #endif | ||
|
|
||
| #ifndef Py_LIMITED_API | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Remove :c:func:`PySlice_GetIndicesEx` function, deprecated since Python 3.7. | ||
| Only remove the function implementation: :c:func:`PySlice_GetIndicesEx` | ||
| remains available as a static inline function, so the API does not change. | ||
| Patch by Victor Stinner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the C API is not affected, I'm not sure that it's worth it to mention this change to users. They should not be affected in practice. (The Changelog can also be removed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, if you want to write tests, please go ahead! I was planning to do that after you told me that length should be evaluated later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #158120.