mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-128863: Deprecate _PyLong_Sign() function (#129176)
Replace _PyLong_Sign() with PyLong_GetSign().
This commit is contained in:
parent
0093a31273
commit
1d485db953
9 changed files with 29 additions and 15 deletions
|
@ -428,9 +428,10 @@ float_richcompare(PyObject *v, PyObject *w, int op)
|
|||
|
||||
else if (PyLong_Check(w)) {
|
||||
int vsign = i == 0.0 ? 0 : i < 0.0 ? -1 : 1;
|
||||
int wsign = _PyLong_Sign(w);
|
||||
int wsign;
|
||||
int exponent;
|
||||
|
||||
(void)PyLong_GetSign(w, &wsign);
|
||||
if (vsign != wsign) {
|
||||
/* Magnitudes are irrelevant -- the signs alone
|
||||
* determine the outcome.
|
||||
|
|
|
@ -827,19 +827,25 @@ PyLong_IsZero(PyObject *obj)
|
|||
return _PyLong_IsZero((PyLongObject *)obj);
|
||||
}
|
||||
|
||||
int
|
||||
_PyLong_Sign(PyObject *vv)
|
||||
static int
|
||||
long_sign(PyObject *vv)
|
||||
{
|
||||
assert(vv != NULL);
|
||||
assert(PyLong_Check(vv));
|
||||
PyLongObject *v = (PyLongObject *)vv;
|
||||
|
||||
assert(v != NULL);
|
||||
assert(PyLong_Check(v));
|
||||
if (_PyLong_IsCompact(v)) {
|
||||
return _PyLong_CompactSign(v);
|
||||
}
|
||||
return _PyLong_NonCompactSign(v);
|
||||
}
|
||||
|
||||
int
|
||||
_PyLong_Sign(PyObject *vv)
|
||||
{
|
||||
return long_sign(vv);
|
||||
}
|
||||
|
||||
int
|
||||
PyLong_GetSign(PyObject *vv, int *sign)
|
||||
{
|
||||
|
@ -848,7 +854,7 @@ PyLong_GetSign(PyObject *vv, int *sign)
|
|||
return -1;
|
||||
}
|
||||
|
||||
*sign = _PyLong_Sign(vv);
|
||||
*sign = long_sign(vv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -399,11 +399,14 @@ _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
|
|||
step_is_negative = 0;
|
||||
}
|
||||
else {
|
||||
int step_sign;
|
||||
step = evaluate_slice_index(self->step);
|
||||
if (step == NULL)
|
||||
if (step == NULL) {
|
||||
goto error;
|
||||
step_sign = _PyLong_Sign(step);
|
||||
}
|
||||
assert(PyLong_Check(step));
|
||||
|
||||
int step_sign;
|
||||
(void)PyLong_GetSign(step, &step_sign);
|
||||
if (step_sign == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"slice step cannot be zero");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue