summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-06-03 12:06:31 (GMT)
committerGitHub <noreply@github.com>2024-06-03 12:06:31 (GMT)
commit61d3ab32da92e70bb97a544d76ef2b837501024f (patch)
tree46a12c70cc83c83e4e6942f0b7a7aa63191addb5 /Include/cpython
parent367adc91fb9834eb35b168048fd54705621c3f21 (diff)
downloadcpython-61d3ab32da92e70bb97a544d76ef2b837501024f.zip
cpython-61d3ab32da92e70bb97a544d76ef2b837501024f.tar.gz
cpython-61d3ab32da92e70bb97a544d76ef2b837501024f.tar.bz2
gh-116560: Add PyLong_GetSign() public function (#116561)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/longobject.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/Include/cpython/longobject.h b/Include/cpython/longobject.h
index 9681593..19a6722 100644
--- a/Include/cpython/longobject.h
+++ b/Include/cpython/longobject.h
@@ -55,9 +55,13 @@ 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_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
-// v must not be NULL, and must be a normalized long.
-// There are no error cases.
+/* 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);
/* _PyLong_NumBits. Return the number of bits needed to represent the