Commit 58694756 authored by Stefan Behnel's avatar Stefan Behnel

streamline yield object unwrapping in async-gen

parent 07dc6bfd
...@@ -396,13 +396,14 @@ static PyObject * ...@@ -396,13 +396,14 @@ static PyObject *
__Pyx_async_gen_unwrap_value(__pyx_AsyncGenObject *gen, PyObject *result) __Pyx_async_gen_unwrap_value(__pyx_AsyncGenObject *gen, PyObject *result)
{ {
if (result == NULL) { if (result == NULL) {
if (!PyErr_Occurred()) { PyObject *exc_type = PyErr_Occurred();
if (!exc_type) {
PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
} gen->ag_closed = 1;
} else if (exc_type == __Pyx_PyExc_StopAsyncIteration
if (PyErr_ExceptionMatches(__Pyx_PyExc_StopAsyncIteration) || exc_type == PyExc_GeneratorExit
|| PyErr_ExceptionMatches(PyExc_GeneratorExit) || PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration)
) { || PyErr_GivenExceptionMatches(exc_type, PyExc_GeneratorExit)) {
gen->ag_closed = 1; gen->ag_closed = 1;
} }
...@@ -411,12 +412,8 @@ __Pyx_async_gen_unwrap_value(__pyx_AsyncGenObject *gen, PyObject *result) ...@@ -411,12 +412,8 @@ __Pyx_async_gen_unwrap_value(__pyx_AsyncGenObject *gen, PyObject *result)
if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) { if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) {
/* async yield */ /* async yield */
PyObject *e = __Pyx_PyObject_CallOneArg( __Pyx_ReturnWithStopIteration(((__pyx__PyAsyncGenWrappedValue*)result)->val);
PyExc_StopIteration,
((__pyx__PyAsyncGenWrappedValue*)result)->val);
Py_DECREF(result); Py_DECREF(result);
PyErr_SetObject(PyExc_StopIteration, e);
Py_DECREF(e);
return NULL; return NULL;
} }
...@@ -692,7 +689,7 @@ __pyx__PyAsyncGenWrapValue(PyObject *val) ...@@ -692,7 +689,7 @@ __pyx__PyAsyncGenWrapValue(PyObject *val)
_Py_NewReference((PyObject*)o); _Py_NewReference((PyObject*)o);
} else { } else {
o = PyObject_New(__pyx__PyAsyncGenWrappedValue, __pyx__PyAsyncGenWrappedValueType); o = PyObject_New(__pyx__PyAsyncGenWrappedValue, __pyx__PyAsyncGenWrappedValueType);
if (o == NULL) { if (unlikely(!o)) {
Py_DECREF(val); Py_DECREF(val);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment