gh-121567: Improve `slice` C-API docs by mentioning exceptions (#121568)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
sobolevn 2024-07-10 13:56:44 +03:00 committed by GitHub
parent cced22c760
commit 84a5597b08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -23,7 +23,9 @@ Slice Objects
Return a new slice object with the given values. The *start*, *stop*, and Return a new slice object with the given values. The *start*, *stop*, and
*step* parameters are used as the values of the slice object attributes of *step* parameters are used as the values of the slice object attributes of
the same names. Any of the values may be ``NULL``, in which case the the same names. Any of the values may be ``NULL``, in which case the
``None`` will be used for the corresponding attribute. Return ``NULL`` if ``None`` will be used for the corresponding attribute.
Return ``NULL`` with an exception set if
the new object could not be allocated. the new object could not be allocated.
@ -52,7 +54,7 @@ Slice Objects
of bounds indices are clipped in a manner consistent with the handling of of bounds indices are clipped in a manner consistent with the handling of
normal slices. normal slices.
Returns ``0`` on success and ``-1`` on error with exception set. Return ``0`` on success and ``-1`` on error with an exception set.
.. note:: .. note::
This function is considered not safe for resizable sequences. This function is considered not safe for resizable sequences.
@ -95,7 +97,7 @@ Slice Objects
``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step ``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step
values less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``. values less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``.
Return ``-1`` on error, ``0`` on success. Return ``-1`` with an exception set on error, ``0`` on success.
.. versionadded:: 3.6.1 .. versionadded:: 3.6.1