mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
gh-116560: Add PyLong_GetSign() public function (#116561)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
367adc91fb
commit
61d3ab32da
7 changed files with 66 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue