@@ -1105,6 +1105,8 @@ can be used to control the execution of the underlying generator function:
11051105 exception), :meth: `close ` returns :const: `None `.
11061106 If the generator yields a value, a :exc: `RuntimeError ` is raised.
11071107 If the generator raises any other exception, it is propagated to the caller.
1108+ If a generator returns a value upon being closed, that value is returned
1109+ by :meth: `close `.
11081110
11091111 When a generator iterator is garbage collected before it has exited,
11101112 :meth: `~generator.close ` is called automatically.
@@ -1113,7 +1115,7 @@ can be used to control the execution of the underlying generator function:
11131115
11141116 If a generator returns a value upon being closed, the value is returned
11151117 by :meth: `close `.
1116- Previously, the value was returned from :meth: ` ~generator.close `.
1118+ Previously, it returned `` None ` `.
11171119
11181120
11191121Calling any of the generator methods (:meth: `~generator.__next__ `,
@@ -1209,34 +1211,6 @@ the underlying generator function:
12091211 may be removed in a future version of Python.
12101212
12111213
1212- TODO::: reword agen.aclose()
1213-
1214- Raises a :exc: `GeneratorExit ` exception at the point where the generator
1215- function is currently suspended (equivalent to calling ``throw(GeneratorExit) ``).
1216-
1217- If the generator function has already exited (due to an exception or
1218- normal return), or raises :exc: `GeneratorExit ` (by not catching the
1219- exception), :meth: `close ` returns :const: `None `.
1220- If the generator yields a value, a :exc: `RuntimeError ` is raised.
1221- If the generator raises any other exception, it is propagated to the caller.
1222-
1223- When a generator iterator is garbage collected before it has exited,
1224- :meth: `~generator.close ` is called automatically.
1225-
1226- .. versionchanged :: 3.13
1227-
1228- If a generator returns a value upon being closed, the value is returned
1229- by :meth: `close `.
1230- Previously, the value was returned from :meth: `~generator.close `.
1231-
1232-
1233- Calling any of the generator methods (:meth: `~generator.__next__ `,
1234- :meth: `~generator.send `, :meth: `~generator.throw `, :meth: `~generator.close `)
1235- while one of these methods is already executing
1236- raises a :exc: `ValueError ` exception.
1237-
1238-
1239-
12401214.. index :: pair: exception; GeneratorExit
12411215
12421216.. method :: agen.aclose()
@@ -1252,12 +1226,14 @@ the underlying generator function:
12521226 Any further awaitables returned by subsequent calls to the asynchronous
12531227 generator will raise a :exc: `StopAsyncIteration ` exception.
12541228
1255- If the
1256- asynchronous generator yields a value, a :exc: `RuntimeError ` is raised
1257- by the awaitable. If the asynchronous generator raises any other exception,
1258- it is propagated to the caller of the awaitable. If the asynchronous
1259- generator has already exited due to an exception or normal exit, then
1260- further calls to :meth: `aclose ` will return an awaitable that does nothing.
1229+ If the asynchronous generator yields a value, a :exc: `RuntimeError ` is
1230+ raised by the awaitable.
1231+ If the asynchronous generator raises any other exception, that exception
1232+ is propagated to the caller of the awaitable.
1233+
1234+ If the asynchronous generator has already exited due to an exception or
1235+ normal exit, then further calls to :meth: `aclose ` will return an awaitable
1236+ that does nothing.
12611237
12621238
12631239.. _typesseq :
0 commit comments