gh-91117: Ensure integer mod and pow operations use cached small ints (GH-31843)

This commit is contained in:
Dennis Sweeney 2022-04-11 16:07:09 -04:00 committed by GitHub
parent a8abb76af9
commit 8be8949116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View file

@ -2679,6 +2679,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
}
else {
z = x_divrem(a, b, prem);
*prem = maybe_small_long(*prem);
if (z == NULL)
return -1;
}
@ -2732,6 +2733,7 @@ long_rem(PyLongObject *a, PyLongObject *b, PyLongObject **prem)
else {
/* Slow path using divrem. */
Py_XDECREF(x_divrem(a, b, prem));
*prem = maybe_small_long(*prem);
if (*prem == NULL)
return -1;
}