diff options
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/abstract.c | 13 | ||||
| -rw-r--r-- | Objects/bytearrayobject.c | 2 | ||||
| -rw-r--r-- | Objects/classobject.c | 2 | ||||
| -rw-r--r-- | Objects/codeobject.c | 7 | ||||
| -rw-r--r-- | Objects/complexobject.c | 4 | ||||
| -rw-r--r-- | Objects/enumobject.c | 2 | ||||
| -rw-r--r-- | Objects/floatobject.c | 2 | ||||
| -rw-r--r-- | Objects/sliceobject.c | 6 | ||||
| -rw-r--r-- | Objects/stringobject.c | 2 | ||||
| -rw-r--r-- | Objects/unicodeobject.c | 2 |
10 files changed, 19 insertions, 23 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index aa92ea9156..75c1a10473 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1492,14 +1492,13 @@ PyNumber_Index(PyObject *item) PyObject *result = NULL; if (item == NULL) return null_error(); - if (PyInt_Check(item) || PyLong_Check(item)) { + if (_PyAnyInt_Check(item)) { Py_INCREF(item); return item; } if (PyIndex_Check(item)) { result = item->ob_type->tp_as_number->nb_index(item); - if (result && - !PyInt_Check(result) && !PyLong_Check(result)) { + if (result && !_PyAnyInt_Check(result)) { PyErr_Format(PyExc_TypeError, "__index__ returned non-(int,long) " \ "(type %.200s)", @@ -1574,8 +1573,7 @@ _PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format) return NULL; } - if (integral && (!PyInt_Check(integral) && - !PyLong_Check(integral))) { + if (integral && !_PyAnyInt_Check(integral)) { /* Don't go through tp_as_number->nb_int to avoid hitting the classic class fallback to __trunc__. */ PyObject *int_func = PyObject_GetAttr(integral, int_name); @@ -1586,8 +1584,7 @@ _PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format) Py_DECREF(integral); integral = PyEval_CallObject(int_func, NULL); Py_DECREF(int_func); - if (integral && (!PyInt_Check(integral) && - !PyLong_Check(integral))) { + if (integral && !_PyAnyInt_Check(integral)) { goto non_integral_error; } } @@ -1632,7 +1629,7 @@ PyNumber_Int(PyObject *o) if (m && m->nb_int) { /* This should include subclasses of int */ /* Classic classes always take this branch. */ PyObject *res = m->nb_int(o); - if (res && (!PyInt_Check(res) && !PyLong_Check(res))) { + if (res && !_PyAnyInt_Check(res)) { PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type %.200s)", res->ob_type->tp_name); diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 04c25061ef..c178d9ef65 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -35,7 +35,7 @@ _getbytevalue(PyObject* arg, int *value) *value = Py_CHARMASK(((PyBytesObject*)arg)->ob_sval[0]); return 1; } - else if (PyInt_Check(arg) || PyLong_Check(arg)) { + else if (_PyAnyInt_Check(arg)) { face_value = PyLong_AsLong(arg); } else { diff --git a/Objects/classobject.c b/Objects/classobject.c index 5b645787cb..02d7cfd019 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -1009,7 +1009,7 @@ instance_hash(PyInstanceObject *inst) Py_DECREF(func); if (res == NULL) return -1; - if (PyInt_Check(res) || PyLong_Check(res)) + if (_PyAnyInt_Check(res)) /* This already converts a -1 result to -2. */ outcome = Py_TYPE(res)->tp_hash(res); else { diff --git a/Objects/codeobject.c b/Objects/codeobject.c index a66aa6905a..d50e4c61f0 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -423,10 +423,9 @@ _PyCode_ConstantKey(PyObject *op) /* Py_None is a singleton */ if (op == Py_None - || PyInt_CheckExact(op) - || PyLong_CheckExact(op) - || PyBool_Check(op) - || PyBytes_CheckExact(op) + || _PyAnyInt_CheckExact(op) + || PyBool_Check(op) + || PyBytes_CheckExact(op) #ifdef Py_USING_UNICODE || PyUnicode_CheckExact(op) #endif diff --git a/Objects/complexobject.c b/Objects/complexobject.c index aaefa2dcda..871eea319f 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -796,7 +796,7 @@ complex_richcompare(PyObject *v, PyObject *w, int op) * NotImplemented. Only comparisons with core numeric types raise * TypeError. */ - if (PyInt_Check(w) || PyLong_Check(w) || + if (_PyAnyInt_Check(w) || PyFloat_Check(w) || PyComplex_Check(w)) { PyErr_SetString(PyExc_TypeError, "no ordering relation is defined " @@ -809,7 +809,7 @@ complex_richcompare(PyObject *v, PyObject *w, int op) assert(PyComplex_Check(v)); TO_COMPLEX(v, i); - if (PyInt_Check(w) || PyLong_Check(w)) { + if (_PyAnyInt_Check(w)) { /* Check for 0.0 imaginary part first to avoid the rich * comparison when possible. */ diff --git a/Objects/enumobject.c b/Objects/enumobject.c index 8f86a5b8de..73b656b8e0 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -31,7 +31,7 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_DECREF(en); return NULL; } - assert(PyInt_Check(start) || PyLong_Check(start)); + assert(_PyAnyInt_Check(start)); en->en_index = PyInt_AsSsize_t(start); if (en->en_index == -1 && PyErr_Occurred()) { PyErr_Clear(); diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 37dd67e669..5954d39cdb 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -428,7 +428,7 @@ float_richcompare(PyObject *v, PyObject *w, int op) j = PyFloat_AS_DOUBLE(w); else if (!Py_IS_FINITE(i)) { - if (PyInt_Check(w) || PyLong_Check(w)) + if (_PyAnyInt_Check(w)) /* If i is an infinity, its magnitude exceeds any * finite integer, so it doesn't matter which int we * compare i with. If i is a NaN, similarly. diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 9daeafcc4a..dc18211573 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -107,20 +107,20 @@ PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, if (r->step == Py_None) { *step = 1; } else { - if (!PyInt_Check(r->step) && !PyLong_Check(r->step)) return -1; + if (!_PyAnyInt_Check(r->step)) return -1; *step = PyInt_AsSsize_t(r->step); } if (r->start == Py_None) { *start = *step < 0 ? length-1 : 0; } else { - if (!PyInt_Check(r->start) && !PyLong_Check(r->start)) return -1; + if (!_PyAnyInt_Check(r->start)) return -1; *start = PyInt_AsSsize_t(r->start); if (*start < 0) *start += length; } if (r->stop == Py_None) { *stop = *step < 0 ? -1 : length; } else { - if (!PyInt_Check(r->stop) && !PyLong_Check(r->stop)) return -1; + if (!_PyAnyInt_Check(r->stop)) return -1; *stop = PyInt_AsSsize_t(r->stop); if (*stop < 0) *stop += length; } diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 59d22e7694..b21afb4424 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4504,7 +4504,7 @@ PyString_Format(PyObject *format, PyObject *args) if (PyNumber_Check(v)) { PyObject *iobj=NULL; - if (PyInt_Check(v) || (PyLong_Check(v))) { + if (_PyAnyInt_Check(v)) { iobj = v; Py_INCREF(iobj); } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index d011f7d50c..8bf04df2c8 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8628,7 +8628,7 @@ PyObject *PyUnicode_Format(PyObject *format, if (PyNumber_Check(v)) { PyObject *iobj=NULL; - if (PyInt_Check(v) || (PyLong_Check(v))) { + if (_PyAnyInt_Check(v)) { iobj = v; Py_INCREF(iobj); } |
