summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-06-02 22:43:51 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-06-02 22:43:51 (GMT)
commitaab3c4a2110c3184ac0e9fc843fb1f3e07fbaf53 (patch)
tree25366f646da729ac7c4f351f5cbacc763b866ac6 /Lib
parent231d90609b026dc709efd16d5bda610fbb12ebad (diff)
downloadcpython-aab3c4a2110c3184ac0e9fc843fb1f3e07fbaf53.zip
cpython-aab3c4a2110c3184ac0e9fc843fb1f3e07fbaf53.tar.gz
cpython-aab3c4a2110c3184ac0e9fc843fb1f3e07fbaf53.tar.bz2
Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_coroutines.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index e79896a..670852d 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -995,6 +995,26 @@ class SysSetCoroWrapperTest(unittest.TestCase):
sys.set_coroutine_wrapper(1)
self.assertIsNone(sys.get_coroutine_wrapper())
+ def test_set_wrapper_3(self):
+ async def foo():
+ return 'spam'
+
+ def wrapper(coro):
+ async def wrap(coro):
+ return await coro
+ return wrap(coro)
+
+ sys.set_coroutine_wrapper(wrapper)
+ try:
+ with self.assertRaisesRegex(
+ RuntimeError,
+ "coroutine wrapper.*\.wrapper at 0x.*attempted to "
+ "recursively wrap <coroutine.*\.wrap"):
+
+ foo()
+ finally:
+ sys.set_coroutine_wrapper(None)
+
class CAPITest(unittest.TestCase):