gh-112559: Avoid unnecessary conversion attempts to enum_klass in signal.py (#113040)

This commit is contained in:
Yilei Yang 2023-12-23 17:07:52 -08:00 committed by GitHub
parent 0187a7e4ec
commit 050783cb37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 2 deletions

View file

@ -495,6 +495,24 @@ class RunnerTests(BaseTest):
self.assertEqual(1, policy.set_event_loop.call_count)
runner.close()
def test_no_repr_is_call_on_the_task_result(self):
# See https://github.com/python/cpython/issues/112559.
class MyResult:
def __init__(self):
self.repr_count = 0
def __repr__(self):
self.repr_count += 1
return super().__repr__()
async def coro():
return MyResult()
with asyncio.Runner() as runner:
result = runner.run(coro())
self.assertEqual(0, result.repr_count)
if __name__ == '__main__':
unittest.main()