From 849829d6c065353aa52e368a8b9ee6f23af04ed5 Mon Sep 17 00:00:00 2001 From: "roberto@quantal64" Date: Fri, 13 Jul 2012 08:11:14 +0200 Subject: [PATCH] correctly raise exception when the first iteration in a generator fails --- plugins/python/wsgi_subhandler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/python/wsgi_subhandler.c b/plugins/python/wsgi_subhandler.c index e339da9a..3f957530 100644 --- a/plugins/python/wsgi_subhandler.c +++ b/plugins/python/wsgi_subhandler.c @@ -209,7 +209,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { if (!wsgi_req->async_placeholder) { wsgi_req->async_placeholder = PyObject_GetIter(wsgi_req->async_result); if (!wsgi_req->async_placeholder) { - goto clear2; + goto exception; } #ifdef UWSGI_ASYNC if (uwsgi.async > 1) { @@ -221,6 +221,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { pychunk = PyIter_Next(wsgi_req->async_placeholder); if (!pychunk) { +exception: if (PyErr_Occurred()) { int do_exit = uwsgi_python_manage_exceptions(); if (PyErr_ExceptionMatches(PyExc_MemoryError)) { @@ -293,7 +294,6 @@ clear: Py_DECREF((PyObject *)wsgi_req->async_sendfile); } Py_XDECREF((PyObject *)wsgi_req->async_placeholder); -clear2: // send the headers if not already sent if (!wsgi_req->headers_sent && wsgi_req->headers_hvec > 0) {