diff --git a/Objects/genobject.c b/Objects/genobject.c index 937d497753e970..bacd297a84bea1 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -408,8 +408,8 @@ gen_close(PyGenObject *gen, PyObject *args) PyErr_SetString(PyExc_RuntimeError, msg); return NULL; } - if (PyErr_ExceptionMatches(PyExc_StopIteration) - || PyErr_ExceptionMatches(PyExc_GeneratorExit)) { + if (PyErr_ExceptionMatches(PyExc_GeneratorExit) + || PyErr_ExceptionMatches(PyExc_StopIteration)) { PyErr_Clear(); /* ignore these errors */ Py_RETURN_NONE; }