Skip to content

Commit eca9450

Browse files
Detect exception in iterator next call and StopIteration
1 parent 2cf0918 commit eca9450

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/JSObjectProxy.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ PyObject *JSObjectProxyMethodDefinitions::JSObjectProxy_iter_next(JSObjectProxy
320320

321321
PyObject *retVal = JSFunctionProxyMethodDefinitions::JSFunctionProxy_call(nextFunction, PyTuple_New(0), NULL);
322322
Py_DECREF(nextFunction);
323+
if (retVal == NULL) {
324+
if (PyErr_Occurred()) {
325+
PyErr_PrintEx(0);
326+
}
327+
PyErr_SetNone(PyExc_StopIteration);
328+
return NULL;
329+
}
323330

324331
// check if end of iteration
325332
key = PyUnicode_FromString("done");

0 commit comments

Comments
 (0)