Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move __name__ mangling to end of module #156

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions trio_asyncio/_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):

Expand Down Expand Up @@ -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"