gh-116560: Add PyLong_GetSign() public function (#116561)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Sergey B Kirpichev 2024-06-03 15:06:31 +03:00 committed by GitHub
parent 367adc91fb
commit 61d3ab32da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 66 additions and 3 deletions

View file

@ -770,6 +770,18 @@ _PyLong_Sign(PyObject *vv)
return _PyLong_NonCompactSign(v);
}
int
PyLong_GetSign(PyObject *vv, int *sign)
{
if (!PyLong_Check(vv)) {
PyErr_Format(PyExc_TypeError, "expect int, got %T", vv);
return -1;
}
*sign = _PyLong_Sign(vv);
return 0;
}
static int
bit_length_digit(digit x)
{