Sitelet https://github.com/python/cpython/issues/134657
Skip to content

asyncio has underscored names in its __all__ #134657

Description

@JelleZijlstra

Bug report

Bug description:

asyncio has several names in its __all__ that start with an underscore.

Python 3.15.0a0 (heads/assignannos:9081715ff82, May 25 2025, 08:33:06) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> [x for x in asyncio.__all__ if x.startswith("_")]
['_AbstractEventLoopPolicy', '_get_event_loop_policy', '_set_event_loop_policy', '_set_running_loop', '_get_running_loop', '_register_task', '_unregister_task', '_enter_task', '_leave_task', '_DefaultEventLoopPolicy']

That feels wrong: __all__ indicates the public names in the module, and names that start with an underscore are not meant to be public.

In Python 3.13 there were fewer:

['_set_running_loop', '_get_running_loop', '_register_task', '_unregister_task', '_enter_task', '_leave_task']

I propose we remove the new additions in 3.14 in both the 3.14 and main branches, and remove the remaining underscored names in 3.15.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on May 25, 2025
  2. picnixz commented on May 25, 2025

    @picnixz
    Member

    IIRC, the private names were added when the policy system was being deprecated cc @kumaraditya303 (I don't know if it was meant for bc)

  3. added
    3.14bugs and security fixes
    3.15pre-release feature fixes, bugs and security fixes
    on May 25, 2025
  4. JelleZijlstra commented on May 25, 2025

    @JelleZijlstra
    MemberAuthor

    Yes, in #128218. I don't see how re-adding them to __all__ under a different name helps backwards compatibility for anyone; it just makes it slightly easier for people to use the private names.

  5. added a commit that references this issue on May 25, 2025
  6. kumaraditya303 commented on May 26, 2025

    @kumaraditya303
    Contributor

    It wasn't for backwards compatibility, it was to reduce the diff when deprecating it, these underscored functions and classes will be removed in 3.16 anyways so making a lot of name changes didn't seem worth it.

  7. JelleZijlstra commented on Jul 8, 2025

    @JelleZijlstra
    MemberAuthor

    __all__ is a public API; we shouldn't be using it to make other changes more convenient.

  8. added a commit that references this issue on Jul 9, 2025
  9. added a commit that references this issue on Jul 9, 2025
  10. kumaraditya303 commented on Jul 9, 2025

    @kumaraditya303
    Contributor

    Okay, I merged your PR.

  11. added a commit that references this issue on Jul 9, 2025
  12. added a commit that references this issue on Jul 11, 2025
  13. moved this from Todo to Done in asyncioon Jul 11, 2025
  14. added a commit that references this issue on Jul 12, 2025
  15. added a commit that references this issue on Jul 13, 2025
  16. added a commit that references this issue on Aug 4, 2025
  17. added a commit that references this issue on Aug 19, 2025
  18. added a commit that references this issue on Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions