[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479)

This commit is contained in:
Serhiy Storchaka
2018-07-31 09:09:36 +03:00
committed by GitHub
parent dc9039da23
commit 48c8bf21f9
36 changed files with 75 additions and 81 deletions

View File

@@ -617,7 +617,7 @@ static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{
int i;
if (!PyInt_Check(obj) && !PyLong_Check(obj)) {
if (!_PyAnyInt_Check(obj)) {
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",

View File

@@ -1780,7 +1780,7 @@ get_range_long_argument(PyObject *arg, const char *name)
{
PyObject *v;
PyNumberMethods *nb;
if (PyInt_Check(arg) || PyLong_Check(arg)) {
if (_PyAnyInt_Check(arg)) {
Py_INCREF(arg);
return arg;
}
@@ -1795,7 +1795,7 @@ get_range_long_argument(PyObject *arg, const char *name)
v = nb->nb_int(arg);
if (v == NULL)
return NULL;
if (PyInt_Check(v) || PyLong_Check(v))
if (_PyAnyInt_Check(v))
return v;
Py_DECREF(v);
PyErr_SetString(PyExc_TypeError,

View File

@@ -4750,8 +4750,7 @@ _PyEval_SliceIndexNotNone(PyObject *v, Py_ssize_t *pi)
#undef ISINDEX
#define ISINDEX(x) ((x) == NULL || \
PyInt_Check(x) || PyLong_Check(x) || PyIndex_Check(x))
#define ISINDEX(x) ((x) == NULL || _PyAnyInt_Check(x) || PyIndex_Check(x))
static PyObject *
apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */

View File

@@ -1136,7 +1136,7 @@ handle_system_exit(void)
/* If we failed to dig out the 'code' attribute,
just let the else clause below print the error. */
}
if (PyInt_Check(value) || PyLong_Check(value))
if (_PyAnyInt_Check(value))
exitcode = (int)PyInt_AsLong(value);
else {
PyObject *sys_stderr = PySys_GetObject("stderr");