Skip to content

gh-132578: Rename the threading.Thread._handle field #132696

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Apr 18, 2025

Commit 0e9c364 introduced the _handle field on instances of threading.Thread. Unfortunately it's fairly common for subclasses of threading.Thread to define a _handle() method, which is shadowed by the new field.

Search results on GitHub suggests that the new name is unlikely to collide with existing code (results for the old name).

Name mangling is a bit of an awkward fit here because subclasses of threading.Thread need access to the handle.

mpage added 2 commits April 18, 2025 09:47
Commit `0e9c364f` introduced the `_handle` field on instances of
`threading.Thread`. Unfortunately it's fairly common for subclasses
of `threading.Thread` to define a `_handle()` method, which is shadowed
by the new field.
@Yhg1s
Copy link
Member

Yhg1s commented Apr 19, 2025

I'm on the fence about backporting this to 3.13. It has the potential to break code that's started relying on _handle, as well as things that rely on no new attributes being introduced (like debuggers inspecting the Thread object or something). It doesn't feel likely, but neither did _handle clashing with Thread subclasses :P. We don't really want to break things that are not current broken.

How common is the breakage? How much does this block from upgrading to 3.13?

@pitrou
Copy link
Member

pitrou commented Apr 19, 2025

3.13.3 is out already, it sounds unlikely that some library wanting to support 3.13 is still blocked by this bug (the workaround is near trivial). So my vote is against backporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants