Commit 53e62307 authored by Yury Selivanov's avatar Yury Selivanov

Issue #24450: Proxy cr_await and gi_yieldfrom in @types.coroutine

parent e13f8f3c
...@@ -1295,8 +1295,8 @@ class CoroutineTests(unittest.TestCase): ...@@ -1295,8 +1295,8 @@ class CoroutineTests(unittest.TestCase):
self.assertIs(wrapper.__name__, gen.__name__) self.assertIs(wrapper.__name__, gen.__name__)
# Test AttributeErrors # Test AttributeErrors
for name in {'gi_running', 'gi_frame', 'gi_code', for name in {'gi_running', 'gi_frame', 'gi_code', 'gi_yieldfrom',
'cr_running', 'cr_frame', 'cr_code'}: 'cr_running', 'cr_frame', 'cr_code', 'cr_await'}:
with self.assertRaises(AttributeError): with self.assertRaises(AttributeError):
getattr(wrapper, name) getattr(wrapper, name)
...@@ -1304,12 +1304,15 @@ class CoroutineTests(unittest.TestCase): ...@@ -1304,12 +1304,15 @@ class CoroutineTests(unittest.TestCase):
gen.gi_running = object() gen.gi_running = object()
gen.gi_frame = object() gen.gi_frame = object()
gen.gi_code = object() gen.gi_code = object()
gen.gi_yieldfrom = object()
self.assertIs(wrapper.gi_running, gen.gi_running) self.assertIs(wrapper.gi_running, gen.gi_running)
self.assertIs(wrapper.gi_frame, gen.gi_frame) self.assertIs(wrapper.gi_frame, gen.gi_frame)
self.assertIs(wrapper.gi_code, gen.gi_code) self.assertIs(wrapper.gi_code, gen.gi_code)
self.assertIs(wrapper.gi_yieldfrom, gen.gi_yieldfrom)
self.assertIs(wrapper.cr_running, gen.gi_running) self.assertIs(wrapper.cr_running, gen.gi_running)
self.assertIs(wrapper.cr_frame, gen.gi_frame) self.assertIs(wrapper.cr_frame, gen.gi_frame)
self.assertIs(wrapper.cr_code, gen.gi_code) self.assertIs(wrapper.cr_code, gen.gi_code)
self.assertIs(wrapper.cr_await, gen.gi_yieldfrom)
wrapper.close() wrapper.close()
gen.close.assert_called_once_with() gen.close.assert_called_once_with()
......
...@@ -188,9 +188,13 @@ class _GeneratorWrapper: ...@@ -188,9 +188,13 @@ class _GeneratorWrapper:
@property @property
def gi_running(self): def gi_running(self):
return self.__wrapped.gi_running return self.__wrapped.gi_running
@property
def gi_yieldfrom(self):
return self.__wrapped.gi_yieldfrom
cr_code = gi_code cr_code = gi_code
cr_frame = gi_frame cr_frame = gi_frame
cr_running = gi_running cr_running = gi_running
cr_await = gi_yieldfrom
def __next__(self): def __next__(self):
return next(self.__wrapped) return next(self.__wrapped)
def __iter__(self): def __iter__(self):
......
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