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

@ -92,6 +92,19 @@ pylong_fromnativebytes(PyObject *module, PyObject *args)
return res;
}
static PyObject *
pylong_getsign(PyObject *module, PyObject *arg)
{
int sign;
NULLABLE(arg);
if (PyLong_GetSign(arg, &sign) == -1) {
return NULL;
}
return PyLong_FromLong(sign);
}
static PyObject *
pylong_aspid(PyObject *module, PyObject *arg)
{
@ -109,6 +122,7 @@ static PyMethodDef test_methods[] = {
{"pylong_fromunicodeobject", pylong_fromunicodeobject, METH_VARARGS},
{"pylong_asnativebytes", pylong_asnativebytes, METH_VARARGS},
{"pylong_fromnativebytes", pylong_fromnativebytes, METH_VARARGS},
{"pylong_getsign", pylong_getsign, METH_O},
{"pylong_aspid", pylong_aspid, METH_O},
{NULL},
};