mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +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
|
@ -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},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue