[Python-checkins] Port regression test for issue GH-93592 (GH-96208) (GH-96313)

markshannon webhook-mailer at python.org
Fri Aug 26 11:02:47 EDT 2022


https://github.com/python/cpython/commit/acd7841aa4e103d8d9ca33cbfc8100578211a602
commit: acd7841aa4e103d8d9ca33cbfc8100578211a602
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: markshannon <mark at hotpy.org>
date: 2022-08-26T16:02:36+01:00
summary:

Port regression test for issue GH-93592 (GH-96208) (GH-96313)

files:
M Lib/test/test_coroutines.py

diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index dba5ceffaf1..8fff2d47c10 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -4,6 +4,7 @@
 import pickle
 import sys
 import types
+import traceback
 import unittest
 import warnings
 from test import support
@@ -2207,6 +2208,29 @@ async def f():
         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,



More information about the Python-checkins mailing list