summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-27 13:09:36 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-27 13:09:36 (GMT)
commit994f04dbf576f4ebafb9de2bc6821e15cb0de0ea (patch)
tree4967ed9c9688f7fe035c646de993c337141051b0 /Objects/intobject.c
parent58c2c6ebb893917e759cc1401b0d862b3f7c1a94 (diff)
downloadcpython-994f04dbf576f4ebafb9de2bc6821e15cb0de0ea.zip
cpython-994f04dbf576f4ebafb9de2bc6821e15cb0de0ea.tar.gz
cpython-994f04dbf576f4ebafb9de2bc6821e15cb0de0ea.tar.bz2
Issue #28998: More APIs now support longs as well as ints.
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r--Objects/intobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 0c5ea65..04e4d29 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -155,6 +155,11 @@ PyInt_AsLong(register PyObject *op)
return -1;
}
+ if (PyLong_CheckExact(op)) {
+ /* avoid creating temporary int object */
+ return PyLong_AsLong(op);
+ }
+
io = (PyIntObject*) (*nb->nb_int) (op);
if (io == NULL)
return -1;
@@ -163,8 +168,6 @@ PyInt_AsLong(register PyObject *op)
/* got a long? => retry int conversion */
val = PyLong_AsLong((PyObject *)io);
Py_DECREF(io);
- if ((val == -1) && PyErr_Occurred())
- return -1;
return val;
}
else