From 1baac19e82fc0906f27832725f954243c50fc53e Mon Sep 17 00:00:00 2001 From: Stefan Behnel <stefan_ml@behnel.de> Date: Fri, 18 Aug 2017 11:36:32 +0200 Subject: [PATCH] Do not issue 'never awaited' warning for generators (only for coroutines). --- Cython/Utility/Coroutine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c index 973767efd..603105fca 100644 --- a/Cython/Utility/Coroutine.c +++ b/Cython/Utility/Coroutine.c @@ -1067,6 +1067,12 @@ static void __Pyx_Coroutine_del(PyObject *self) { #endif if (unlikely(gen->resume_label == 0 && !error_value)) { +#ifdef __Pyx_Coroutine_USED +#ifdef __Pyx_Generator_USED + // only warn about (async) coroutines + if (!__Pyx_Generator_CheckExact(self)) +#endif + { // untrack dead object as we are executing Python code (which might trigger GC) PyObject_GC_UnTrack(self); #if PY_VERSION_HEX >= 0x03030000 || defined(PyErr_WarnFormat) @@ -1117,6 +1123,8 @@ static void __Pyx_Coroutine_del(PyObject *self) { Py_XDECREF(msg);} #endif PyObject_GC_Track(self); + } +#endif /*__Pyx_Coroutine_USED*/ } else { PyObject *res = __Pyx_Coroutine_Close(self); if (unlikely(!res)) { -- 2.30.9