bpo-39764: Make Task.get_stack accept ag_frame (GH-18669)


Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 4482337decdbd0c6e2150346a68b3616bda664aa)

Co-authored-by: Lidi Zheng <scallopsky@gmail.com>
diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py
index fb6321d..62bf877 100644
--- a/Lib/test/test_asyncgen.py
+++ b/Lib/test/test_asyncgen.py
@@ -1191,5 +1191,20 @@
 
         self.loop.run_until_complete(run())
 
+    def test_async_gen_aclose_compatible_with_get_stack(self):
+        async def async_generator():
+            yield object()
+
+        async def run():
+            ag = async_generator()
+            asyncio.create_task(ag.aclose())
+            tasks = asyncio.all_tasks()
+            for task in tasks:
+                # No AttributeError raised
+                task.get_stack()
+
+        self.loop.run_until_complete(run())
+
+
 if __name__ == "__main__":
     unittest.main()