From: Ben Darnell Date: Sat, 10 Jan 2015 15:47:19 +0000 (-0500) Subject: Clarify docs: `return` in generator is new in 3.3. X-Git-Tag: v4.1.0b1~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dca3f6bf194d593252bf92203450f8324da1c366;p=thirdparty%2Ftornado.git Clarify docs: `return` in generator is new in 3.3. --- diff --git a/docs/guide/async.rst b/docs/guide/async.rst index 67b702dac..7430031f3 100644 --- a/docs/guide/async.rst +++ b/docs/guide/async.rst @@ -110,4 +110,9 @@ the original synchronous version:: response = yield http_client.fetch(url) raise gen.Return(response.body) -The statement ``raise gen.Return(response.body)`` is an artifact of Python 2, in which generators aren't allowed to return values. To overcome this, Tornado coroutines raise a special kind of exception called a ``Return``. The coroutine catches this exception and treats it like a returned value. In Python 3, a ``return response.body`` achieves the same result. +The statement ``raise gen.Return(response.body)`` is an artifact of +Python 2 (and 3.2), in which generators aren't allowed to return +values. To overcome this, Tornado coroutines raise a special kind of +exception called a `.Return`. The coroutine catches this exception and +treats it like a returned value. In Python 3.3 and later, a ``return +response.body`` achieves the same result.