]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_csv: use _PyLong_AsInt()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 19 Oct 2016 14:00:37 +0000 (16:00 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 19 Oct 2016 14:00:37 +0000 (16:00 +0200)
Modules/_csv.c

index 7a78541bf2d70a72dac5d6a3e180e5f4b6cca1e7..e5324ae91a52143c2dcd6ceb0a49afc23b3cd18e 100644 (file)
@@ -209,23 +209,17 @@ _set_int(const char *name, int *target, PyObject *src, int dflt)
     if (src == NULL)
         *target = dflt;
     else {
-        long value;
+        int value;
         if (!PyLong_CheckExact(src)) {
             PyErr_Format(PyExc_TypeError,
                          "\"%s\" must be an integer", name);
             return -1;
         }
-        value = PyLong_AsLong(src);
-        if (value == -1 && PyErr_Occurred())
-            return -1;
-#if SIZEOF_LONG > SIZEOF_INT
-        if (value > INT_MAX || value < INT_MIN) {
-            PyErr_Format(PyExc_ValueError,
-                         "integer out of range for \"%s\"", name);
+        value = _PyLong_AsInt(src);
+        if (value == -1 && PyErr_Occurred()) {
             return -1;
         }
-#endif
-        *target = (int)value;
+        *target = value;
     }
     return 0;
 }