summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-10-27 16:12:53 (GMT)
committerGitHub <noreply@github.com>2020-10-27 16:12:53 (GMT)
commit37834136d0afe51d274bfc79d8705514cbe73727 (patch)
tree0e4c6b1f42813363f690e7ad179874d727d2cd79 /Modules/mathmodule.c
parenta6879d9445f98833c4e300e187956e2a218a2315 (diff)
downloadcpython-37834136d0afe51d274bfc79d8705514cbe73727.zip
cpython-37834136d0afe51d274bfc79d8705514cbe73727.tar.gz
cpython-37834136d0afe51d274bfc79d8705514cbe73727.tar.bz2
bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)
Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory. _cursesmodule.c and zoneinfo.c are now built with Py_BUILD_CORE_MODULE macro defined.
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r--Modules/mathmodule.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 45b0302..86b64fb 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -55,6 +55,7 @@ raised for division by zero and mod by zero.
#include "Python.h"
#include "pycore_bitutils.h" // _Py_bit_length()
#include "pycore_dtoa.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "_math.h"
#include "clinic/mathmodule.c.h"
@@ -850,7 +851,7 @@ math_gcd(PyObject *module, PyObject * const *args, Py_ssize_t nargs)
Py_DECREF(res);
return NULL;
}
- if (res == _PyLong_One) {
+ if (res == _PyLong_GetOne()) {
/* Fast path: just check arguments.
It is okay to use identity comparison here. */
Py_DECREF(x);
@@ -923,7 +924,7 @@ math_lcm(PyObject *module, PyObject * const *args, Py_ssize_t nargs)
Py_DECREF(res);
return NULL;
}
- if (res == _PyLong_Zero) {
+ if (res == _PyLong_GetZero()) {
/* Fast path: just check arguments.
It is okay to use identity comparison here. */
Py_DECREF(x);
@@ -1837,7 +1838,7 @@ math_isqrt(PyObject *module, PyObject *n)
}
if (a_too_large) {
- Py_SETREF(a, PyNumber_Subtract(a, _PyLong_One));
+ Py_SETREF(a, PyNumber_Subtract(a, _PyLong_GetOne()));
}
Py_DECREF(n);
return a;
@@ -3295,7 +3296,7 @@ math_perm_impl(PyObject *module, PyObject *n, PyObject *k)
factor = n;
Py_INCREF(factor);
for (i = 1; i < factors; ++i) {
- Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_One));
+ Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_GetOne()));
if (factor == NULL) {
goto error;
}
@@ -3417,7 +3418,7 @@ math_comb_impl(PyObject *module, PyObject *n, PyObject *k)
factor = n;
Py_INCREF(factor);
for (i = 1; i < factors; ++i) {
- Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_One));
+ Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_GetOne()));
if (factor == NULL) {
goto error;
}