mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully
This commit is contained in:
parent
231d90609b
commit
aab3c4a211
6 changed files with 68 additions and 10 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue