summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2022-08-26 14:07:31 (GMT)
committerGitHub <noreply@github.com>2022-08-26 14:07:31 (GMT)
commit771eff21a0984327a95013e2bd1d57b1f1a0e89d (patch)
treed7b8c7eb9a08b252364c5bb799d40fff1e252e32
parent8c1dbad36f44f332dadd9d08c8ffe3da7f6a20a6 (diff)
downloadcpython-771eff21a0984327a95013e2bd1d57b1f1a0e89d.zip
cpython-771eff21a0984327a95013e2bd1d57b1f1a0e89d.tar.gz
cpython-771eff21a0984327a95013e2bd1d57b1f1a0e89d.tar.bz2
Port regression test for issue GH-93592 (GH-96208)
-rw-r--r--Lib/test/test_coroutines.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index dba5cef..8fff2d4 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -4,6 +4,7 @@ import inspect
import pickle
import sys
import types
+import traceback
import unittest
import warnings
from test import support
@@ -2207,6 +2208,29 @@ class CoroutineTest(unittest.TestCase):
with self.assertWarns(RuntimeWarning):
gen.cr_frame.clear()
+ def test_stack_in_coroutine_throw(self):
+ # Regression test for https://github.com/python/cpython/issues/93592
+ async def a():
+ return await b()
+
+ async def b():
+ return await c()
+
+ @types.coroutine
+ def c():
+ try:
+ # traceback.print_stack()
+ yield len(traceback.extract_stack())
+ except ZeroDivisionError:
+ # traceback.print_stack()
+ yield len(traceback.extract_stack())
+
+ coro = a()
+ len_send = coro.send(None)
+ len_throw = coro.throw(ZeroDivisionError)
+ # before fixing, visible stack from throw would be shorter than from send.
+ self.assertEqual(len_send, len_throw)
+
@unittest.skipIf(
support.is_emscripten or support.is_wasi,