mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-27867: Add a porting guide for PySlice_GetIndicesEx(). (#1973)
This commit is contained in:
parent
0ccc0f6c74
commit
4d3f084c03
2 changed files with 30 additions and 1 deletions
|
@ -53,6 +53,22 @@ Slice Objects
|
|||
|
||||
Returns ``0`` on success and ``-1`` on error with exception set.
|
||||
|
||||
.. note::
|
||||
This function is considered not safe for resizable sequences.
|
||||
Its invocation should be replaced by a combination of
|
||||
:c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices` where ::
|
||||
|
||||
if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) < 0) {
|
||||
// return error
|
||||
}
|
||||
|
||||
is replaced by ::
|
||||
|
||||
if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {
|
||||
// return error
|
||||
}
|
||||
slicelength = PySlice_AdjustIndices(length, &start, &stop, step);
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
The parameter type for the *slice* parameter was ``PySliceObject*``
|
||||
before.
|
||||
|
@ -61,7 +77,7 @@ Slice Objects
|
|||
If ``Py_LIMITED_API`` is not set or set to the value between ``0x03050400``
|
||||
and ``0x03060000`` (not including) or ``0x03060100`` or higher
|
||||
:c:func:`!PySlice_GetIndicesEx` is implemented as a macro using
|
||||
:c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`.
|
||||
:c:func:`!PySlice_Unpack` and :c:func:`!PySlice_AdjustIndices`.
|
||||
Arguments *start*, *stop* and *step* are evaluated more than once.
|
||||
|
||||
.. deprecated:: 3.6.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue