]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove checking redundantly for checks of PyInt and PyLong.
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 31 Aug 2007 04:32:55 +0000 (04:32 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 31 Aug 2007 04:32:55 +0000 (04:32 +0000)
Modules/_randommodule.c
Modules/_sre.c
Modules/datetimemodule.c
Objects/abstract.c
Objects/floatobject.c
Objects/sliceobject.c
PC/_winreg.c

index 95b7ade9285d7c1908d811b27c9a5b29fdf0d571..bd4d17e3df08d6120cf465466910a1fb4511b8b2 100644 (file)
@@ -231,7 +231,7 @@ random_seed(RandomObject *self, PyObject *args)
        /* If the arg is an int or long, use its absolute value; else use
         * the absolute value of its hash code.
         */
-       if (PyInt_Check(arg) || PyLong_Check(arg))
+       if (PyLong_Check(arg))
                n = PyNumber_Absolute(arg);
        else {
                long hash = PyObject_Hash(arg);
@@ -401,7 +401,7 @@ random_jumpahead(RandomObject *self, PyObject *n)
        PyObject *remobj;
        unsigned long *mt, tmp;
 
-       if (!PyInt_Check(n) && !PyLong_Check(n)) {
+       if (!PyLong_Check(n)) {
                PyErr_Format(PyExc_TypeError, "jumpahead requires an "
                             "integer, not '%s'",
                             Py_Type(n)->tp_name);
index 20f98ca4591b20f6b8296134354e32a071924e06..03067cb6ae6460fb09a1758df05d036a2e6155c8 100644 (file)
@@ -2764,7 +2764,7 @@ match_getindex(MatchObject* self, PyObject* index)
     if (self->pattern->groupindex) {
         index = PyObject_GetItem(self->pattern->groupindex, index);
         if (index) {
-            if (PyInt_Check(index) || PyLong_Check(index))
+            if (PyLong_Check(index))
                 i = PyInt_AsSsize_t(index);
             Py_DECREF(index);
         } else
index 046354cd5fc6baeed8a701b880b21e321a334196..14990a38e2d2e5f5ef12f5695dc721810b7a4fd0 100644 (file)
@@ -1758,11 +1758,11 @@ delta_multiply(PyObject *left, PyObject *right)
 
        if (PyDelta_Check(left)) {
                /* delta * ??? */
-               if (PyInt_Check(right) || PyLong_Check(right))
+               if (PyLong_Check(right))
                        result = multiply_int_timedelta(right,
                                        (PyDateTime_Delta *) left);
        }
-       else if (PyInt_Check(left) || PyLong_Check(left))
+       else if (PyLong_Check(left))
                result = multiply_int_timedelta(left,
                                                (PyDateTime_Delta *) right);
 
@@ -1778,7 +1778,7 @@ delta_divide(PyObject *left, PyObject *right)
 
        if (PyDelta_Check(left)) {
                /* delta * ??? */
-               if (PyInt_Check(right) || PyLong_Check(right))
+               if (PyLong_Check(right))
                        result = divide_timedelta_int(
                                        (PyDateTime_Delta *)left,
                                        right);
@@ -1807,7 +1807,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
 
        assert(num != NULL);
 
-       if (PyInt_Check(num) || PyLong_Check(num)) {
+       if (PyLong_Check(num)) {
                prod = PyNumber_Multiply(num, factor);
                if (prod == NULL)
                        return NULL;
@@ -1855,7 +1855,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
                 * fractional part requires float arithmetic, and may
                 * lose a little info.
                 */
-               assert(PyInt_Check(factor) || PyLong_Check(factor));
+               assert(PyLong_Check(factor));
                dnum = PyLong_AsDouble(factor);
 
                dnum *= fracpart;
index 8eb0feaf9dc2bd5f7c6885767ff0ddfc283b2edf..8d213b2d9448e010ba2d2084e2b9ec43a1a258f1 100644 (file)
@@ -1153,14 +1153,13 @@ PyNumber_Index(PyObject *item)
        PyObject *result = NULL;
        if (item == NULL)
                return null_error();
-       if (PyInt_Check(item) || PyLong_Check(item)) {
+       if (PyLong_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 && !PyLong_Check(result)) {
                        PyErr_Format(PyExc_TypeError,
                                     "__index__ returned non-int "
                                     "(type %.200s)",
@@ -1270,7 +1269,7 @@ PyNumber_Long(PyObject *o)
        }
        if (m && m->nb_long) { /* This should include subclasses of long */
                PyObject *res = m->nb_long(o);
-               if (res && (!PyInt_Check(res) && !PyLong_Check(res))) {
+               if (res && !PyLong_Check(res)) {
                        PyErr_Format(PyExc_TypeError,
                                     "__long__ returned non-long (type %.200s)",
                                     res->ob_type->tp_name);
index c060d8b7576059d11c85dfe0dad9f107851b5a25..7c489d9e6cf63fcdfc4fb29b58cdba4fd1551707 100644 (file)
@@ -331,7 +331,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 (PyLong_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.
index eb66c79b572136b1ef02e69776794715a5b33840..d160b07e4ea0a929e2f92c028b1ca1c906da3336 100644 (file)
@@ -106,7 +106,7 @@ 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 (!PyLong_Check(r->step)) return -1;
                *step = PyInt_AsSsize_t(r->step);
        }
        if (r->start == Py_None) {
index 7386ea10c79d0454ecc4ef157ea8f92647f04813..ddb6b2c985f1d92addc8c9354424bb625bd46c93 100644 (file)
@@ -575,7 +575,7 @@ PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK)
                PyHKEYObject *pH = (PyHKEYObject *)ob;
                *pHANDLE = pH->hkey;
        }
-       else if (PyInt_Check(ob) || PyLong_Check(ob)) {
+       else if (PyLong_Check(ob)) {
                /* We also support integers */
                PyErr_Clear();
                *pHANDLE = (HKEY)PyLong_AsVoidPtr(ob);