diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-10-19 14:00:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-10-19 14:00:37 (GMT) |
commit | 7a6dbb71b24eb4693a3834230088defcd751f476 (patch) | |
tree | d90f3889cb72148acd1d5b8ef049d2ab391939ce /Modules/_csv.c | |
parent | af48a917158dd2ce339a8d7bbb769ff2f37809b4 (diff) | |
download | cpython-7a6dbb71b24eb4693a3834230088defcd751f476.zip cpython-7a6dbb71b24eb4693a3834230088defcd751f476.tar.gz cpython-7a6dbb71b24eb4693a3834230088defcd751f476.tar.bz2 |
_csv: use _PyLong_AsInt()
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 7a78541..e5324ae 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -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; } |