File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 4
4
import pickle
5
5
import sys
6
6
import types
7
+ import traceback
7
8
import unittest
8
9
import warnings
9
10
from test import support
@@ -2207,6 +2208,29 @@ async def f():
2207
2208
with self .assertWarns (RuntimeWarning ):
2208
2209
gen .cr_frame .clear ()
2209
2210
2211
+ def test_stack_in_coroutine_throw (self ):
2212
+ # Regression test for https://github.com/python/cpython/issues/93592
2213
+ async def a ():
2214
+ return await b ()
2215
+
2216
+ async def b ():
2217
+ return await c ()
2218
+
2219
+ @types .coroutine
2220
+ def c ():
2221
+ try :
2222
+ # traceback.print_stack()
2223
+ yield len (traceback .extract_stack ())
2224
+ except ZeroDivisionError :
2225
+ # traceback.print_stack()
2226
+ yield len (traceback .extract_stack ())
2227
+
2228
+ coro = a ()
2229
+ len_send = coro .send (None )
2230
+ len_throw = coro .throw (ZeroDivisionError )
2231
+ # before fixing, visible stack from throw would be shorter than from send.
2232
+ self .assertEqual (len_send , len_throw )
2233
+
2210
2234
2211
2235
@unittest .skipIf (
2212
2236
support .is_emscripten or support .is_wasi ,
You can’t perform that action at this time.
0 commit comments