From 2e36f7b5e8475efde0702f9d8771a9de94d97aab Mon Sep 17 00:00:00 2001 From: Noah Kim Date: Fri, 7 Mar 2025 16:24:50 -0500 Subject: [PATCH] Move __name__ mangling to end of module --- trio_asyncio/_loop.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/trio_asyncio/_loop.py b/trio_asyncio/_loop.py index a48e9f4..58edfc5 100644 --- a/trio_asyncio/_loop.py +++ b/trio_asyncio/_loop.py @@ -190,12 +190,6 @@ def set_event_loop(self, loop): super().set_event_loop(loop) -# get_event_loop() without a running loop is deprecated in 3.12+. The logic for emitting the -# DeprecationWarning walks the stack looking at module names in order to associate it with -# the first caller outside asyncio. We need to pretend to be asyncio in order for that to work. -if sys.version_info >= (3, 12): - __name__ = "asyncio.fake.trio_asyncio._loop" - # Make sure we don't try to continue using the Trio loop after a fork() if hasattr(os, "register_at_fork"): @@ -687,3 +681,10 @@ def run_trio_task(proc, *args): will propagate to, and terminate, the trio-asyncio loop. """ _running_loop().run_trio_task(proc, *args) + + +# get_event_loop() without a running loop is deprecated in 3.12+. The logic for emitting the +# DeprecationWarning walks the stack looking at module names in order to associate it with +# the first caller outside asyncio. We need to pretend to be asyncio in order for that to work. +if sys.version_info >= (3, 12): + __name__ = "asyncio.fake.trio_asyncio._loop"