Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
skirpichev and vstinner authored Jun 3, 2024
commit 12c6aa0c6a7d274e331a87f63e5df7550fed90c7
6 changes: 3 additions & 3 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.

.. c:function:: int PyLong_GetSign(PyObject *obj, int *sign)

Retrieve the sign of integer object *obj* (``0``, ``-1`` or ``+1`` for zero,
negative or positive integer, respectively) in a variable *sign*.
Get the sign of the integer object *obj*: ``0``, ``-1`` or ``+1`` for zero,
negative or positive integer, respectively.

Return ``0`` on success, else ``-1`` with an exception set. This function
always succeeds if *obj* is a :c:type:`PyLongObject` or its subtype.

.. versionadded:: 3.13
.. versionadded:: 3.14


.. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op)
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,8 @@ New Features
between native integer types and Python :class:`int` objects.
(Contributed by Steve Dower in :gh:`111140`.)

* Add :c:func:`PyLong_GetSign` function to test sign of :class:`int` objects.
Contributed by Sergey B Kirpichev.
* Add :c:func:`PyLong_GetSign` function to get the sign of :class:`int` objects.
(Contributed by Sergey B Kirpichev in :gh:`116560`.)

* Add :c:func:`PyType_GetFullyQualifiedName` function to get the type's fully
qualified name. Equivalent to ``f"{type.__module__}.{type.__qualname__}"``,
Expand Down
7 changes: 5 additions & 2 deletions Include/cpython/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ PyAPI_FUNC(PyObject*) PyLong_FromUnsignedNativeBytes(const void* buffer,
PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op);
PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op);

/* PyLong_GetSign. Retrieve the sign of the integer value (0, -1 or +1) in
a variable sign. Return 0 on success, else -1 with an exception set. */
/* PyLong_GetSign. Get the sign of an integer object:
* 0, -1 or +1 for zero, negative or positive integer, respectively.
*
* - On success, set '*sign' to the integer sign, and return 0.
* - On failure, set an exception, and return -1. */
PyAPI_FUNC(int) PyLong_GetSign(PyObject *v, int *sign);

PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
Expand Down