MCPcopy Index your code
hub / github.com/python/cpython / test_stack_in_coroutine_throw

Method test_stack_in_coroutine_throw

Lib/test/test_coroutines.py:2245–2266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2243 self.assertIsNone(gen.cr_frame)
2244
2245 def test_stack_in_coroutine_throw(self):
2246 # Regression test for https://github.com/python/cpython/issues/93592
2247 async def a():
2248 return await b()
2249
2250 async def b():
2251 return await c()
2252
2253 @types.coroutine
2254 def c():
2255 try:
2256 # traceback.print_stack()
2257 yield len(traceback.extract_stack())
2258 except ZeroDivisionError:
2259 # traceback.print_stack()
2260 yield len(traceback.extract_stack())
2261
2262 coro = a()
2263 len_send = coro.send(None)
2264 len_throw = coro.throw(ZeroDivisionError)
2265 # before fixing, visible stack from throw would be shorter than from send.
2266 self.assertEqual(len_send, len_throw)
2267
2268 def test_call_generator_in_frame_clear(self):
2269 # gh-143939: Running a generator while clearing the coroutine's frame

Callers

nothing calls this directly

Calls 4

aClass · 0.70
sendMethod · 0.45
throwMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected