[Python-checkins] cpython: _csv: use _PyLong_AsInt()
victor.stinner
python-checkins at python.org
Wed Oct 19 10:02:28 EDT 2016
https://hg.python.org/cpython/rev/ed470e049058
changeset: 104561:ed470e049058
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Oct 19 16:00:37 2016 +0200
summary:
_csv: use _PyLong_AsInt()
files:
Modules/_csv.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/Modules/_csv.c b/Modules/_csv.c
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -209,23 +209,17 @@
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;
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list