From 8d4605e432e585d9afbfc704cd16c55ca7af9e9f Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Fri, 13 Jan 2023 10:14:03 +0100 Subject: [PATCH] switch order of exception match in gen_close --- Objects/genobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/genobject.c b/Objects/genobject.c index 2adb1e4bf308e4..5b0905ead314c8 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -375,8 +375,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; }