summaryrefslogtreecommitdiff
path: root/Objects/intobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r--Objects/intobject.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 1ae8006c28..28182f93db 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -189,6 +189,20 @@ PyInt_AsLong(register PyObject *op)
return val;
}
+int
+_PyInt_AsInt(PyObject *obj)
+{
+ long result = PyInt_AsLong(obj);
+ if (result == -1 && PyErr_Occurred())
+ return -1;
+ if (result > INT_MAX || result < INT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int");
+ return -1;
+ }
+ return (int)result;
+}
+
Py_ssize_t
PyInt_AsSsize_t(register PyObject *op)
{