summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-04-30 19:47:01 (GMT)
committerGeorg Brandl <georg@python.org>2008-04-30 19:47:01 (GMT)
commitaaa6392a1270d5d8e3d8f924ca3dff692f150c13 (patch)
tree7a27328cfbb974dde4cafe197c914200e3cfc24a /Python
parentb041fdaf941e84513c643ac02febfb64a4c77435 (diff)
downloadcpython-aaa6392a1270d5d8e3d8f924ca3dff692f150c13.zip
cpython-aaa6392a1270d5d8e3d8f924ca3dff692f150c13.tar.gz
cpython-aaa6392a1270d5d8e3d8f924ca3dff692f150c13.tar.bz2
Fix nits in builtin next().
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 199ebc0..585059f 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1048,27 +1048,28 @@ builtin_next(PyObject *self, PyObject *args)
return NULL;
if (!PyIter_Check(it)) {
PyErr_Format(PyExc_TypeError,
- "%.200s object is not an iterator", it->ob_type->tp_name);
+ "%.200s object is not an iterator",
+ it->ob_type->tp_name);
return NULL;
}
res = (*it->ob_type->tp_iternext)(it);
- if (res == NULL) {
- if (def) {
- if (PyErr_Occurred() &&
- !PyErr_ExceptionMatches(PyExc_StopIteration))
+ if (res != NULL) {
+ return res;
+ } else if (def != NULL) {
+ if (PyErr_Occurred()) {
+ if(!PyErr_ExceptionMatches(PyExc_StopIteration))
return NULL;
PyErr_Clear();
- Py_INCREF(def);
- return def;
- } else if (PyErr_Occurred()) {
- return NULL;
- } else {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
}
+ Py_INCREF(def);
+ return def;
+ } else if (PyErr_Occurred()) {
+ return NULL;
+ } else {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
}
- return res;
}
PyDoc_STRVAR(next_doc,