summaryrefslogtreecommitdiff
path: root/Objects/iterobject.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-06 14:12:19 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-06 14:12:19 -0800
commit5b4df5813c20fe96f117d0201965b52e86a1a66d (patch)
treed991f61bc824ca1b1b92bf7fb16fe3dacd4b1335 /Objects/iterobject.c
parent3e0bdff8a0793d305b972f4a653e4698d440b3ae (diff)
parent95b272b4e0d5438a12702e51e05d03f5a5a8e505 (diff)
downloadcpython-5b4df5813c20fe96f117d0201965b52e86a1a66d.tar.gz
Includes ensurepip and venv packages in nuget package.
Diffstat (limited to 'Objects/iterobject.c')
-rw-r--r--Objects/iterobject.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index ab29ff81a9..75b2fcbd41 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -208,30 +208,32 @@ calliter_traverse(calliterobject *it, visitproc visit, void *arg)
static PyObject *
calliter_iternext(calliterobject *it)
{
- if (it->it_callable != NULL) {
- PyObject *args = PyTuple_New(0);
- PyObject *result;
- if (args == NULL)
- return NULL;
- result = PyObject_Call(it->it_callable, args, NULL);
- Py_DECREF(args);
- if (result != NULL) {
- int ok;
- ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ);
- if (ok == 0)
- return result; /* Common case, fast path */
- Py_DECREF(result);
- if (ok > 0) {
- Py_CLEAR(it->it_callable);
- Py_CLEAR(it->it_sentinel);
- }
+ PyObject *result;
+
+ if (it->it_callable == NULL) {
+ return NULL;
+ }
+
+ result = _PyObject_CallNoArg(it->it_callable);
+ if (result != NULL) {
+ int ok;
+
+ ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ);
+ if (ok == 0) {
+ return result; /* Common case, fast path */
}
- else if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
- PyErr_Clear();
+
+ Py_DECREF(result);
+ if (ok > 0) {
Py_CLEAR(it->it_callable);
Py_CLEAR(it->it_sentinel);
}
}
+ else if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
+ PyErr_Clear();
+ Py_CLEAR(it->it_callable);
+ Py_CLEAR(it->it_sentinel);
+ }
return NULL;
}