Skip to content

gh-89554: Document _thread.LockType as a class - #150684

Merged
vstinner merged 1 commit into
python:mainfrom
gaborbernat:gh-89554-thread-class-roles
Jun 2, 2026
Merged

gh-89554: Document _thread.LockType as a class#150684
vstinner merged 1 commit into
python:mainfrom
gaborbernat:gh-89554-thread-class-roles

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

_thread.LockType is a class (the type of lock objects), but the documentation marks it with the .. data:: directive, so :class: cross-references to it cannot resolve against a py:class target.

Switch the entry to .. class::.

Refs: gh-89554. Documentation-only change, so no Misc/NEWS entry (skip news).

This file is not covered by CODEOWNERS, so cc @vstinner, who reviews most _thread changes.

@read-the-docs-community

read-the-docs-communityBot commented May 31, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32943671 | 📁 Comparing 1a8a3a8 against main (2f8f569)

🔍 Preview build

5 files changed · ± 5 modified

±Modified

@gaborbernat

Copy link
Copy Markdown
ContributorAuthor

Backward-compatibility check. No independent references to _thread.LockType were found in indexed projects. No breakage.

Comment threadDoc/library/_thread.rst Outdated
.. class:: LockType

This is the type of lock objects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dir() lists the following methods: ['_at_fork_reinit', 'acquire', 'acquire_lock', 'locked', 'locked_lock', 'release', 'release_lock'].

acquire(), release() and locked can be documented. It means moving the existing documentation to here: https://docs.python.org/dev/library/_thread.html#thread.lock.acquire.

To reduce the diff, maybe move the LockType doc where acquire() is currently documented?

@gaborbernat
gaborbernatforce-pushed the gh-89554-thread-class-roles branch from 9c3fc41 to d1af26eCompareJune 1, 2026 15:02
Comment threadDoc/library/_thread.rst
@gaborbernat
gaborbernatforce-pushed the gh-89554-thread-class-roles branch from d1af26e to 77c89a3CompareJune 1, 2026 16:17
@gaborbernat
gaborbernat marked this pull request as draft June 1, 2026 16:26
@gaborbernat
gaborbernatforce-pushed the gh-89554-thread-class-roles branch from 77c89a3 to 343add6CompareJune 1, 2026 16:37
@gaborbernat
gaborbernat marked this pull request as ready for review June 1, 2026 16:46
Comment threadDoc/tools/removed-ids.txt Outdated
c-api/import.html: c.PyImport_LazyImportsMode.PyImport_LAZY_NONE

# gh-89554: _thread lock methods are now documented under the LockType class
library/_thread.html: thread.lock.acquire

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these not be avoided by creating labels at the relevant locations?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in a way the check accepts, unfortunately. These anchors are object IDs emitted by the .. method:: directive, and they keep the dots (thread.lock.acquire). A reST label or target goes through docutils.nodes.make_id(), which collapses every run of non-alphanumeric characters to a single hyphen, so a label can only ever produce thread-lock-acquire — a different anchor. check-html-ids.py compares exact ID strings, so the dotted thread.lock.acquire would still register as removed.

Since the methods are intentionally moving under LockType, removed-ids.txt is the mechanism for recording that rename.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, we could use:

 .. raw:: html
<span id='thread.lock.acquire'></span>

Like we do elsewhere in the documentation.

@gaborbernat
gaborbernat marked this pull request as draft June 1, 2026 20:42
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class. Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
@gaborbernat
gaborbernatforce-pushed the gh-89554-thread-class-roles branch from 343add6 to 1a8a3a8CompareJune 1, 2026 20:44
@gaborbernat
gaborbernat marked this pull request as ready for review June 1, 2026 20:52

@vstinnervstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The LockType class doc is now rendered properly.

I'm not sure about the <span id='...'></span>. I would prefer that @StanFromIreland double check these additions.

@StanFromIrelandStanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That bit is correct, Victor.

@vstinner
vstinner merged commit e37ce56 into python:mainJun 2, 2026
36 checks passed
@github-project-automationgithub-project-automationBot moved this from Todo to Done in Docs PRsJun 2, 2026
@vstinner

Copy link
Copy Markdown
Member

Thanks @gaborbernat for the better doc!

@vstinnervstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 2, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @gaborbernat for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @gaborbernat for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @gaborbernat for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @gaborbernat and @vstinner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e37ce569773b5e4e5c0e6042d4adfde2e9608f13 3.13

@bedevere-app

Copy link
Copy Markdown

GH-150784 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Jun 2, 2026
@bedevere-app

Copy link
Copy Markdown

GH-150785 is a backport of this pull request to the 3.15 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 2, 2026
@bedevere-app

Copy link
Copy Markdown

GH-150786 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Jun 2, 2026
vstinner pushed a commit that referenced this pull request Jun 2, 2026
…50784)
gh-89554: Document _thread.LockType as a class (GH-150684)
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class. Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
(cherry picked from commit e37ce56)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
vstinner pushed a commit that referenced this pull request Jun 2, 2026
…50785)
gh-89554: Document _thread.LockType as a class (GH-150684)
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class. Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
(cherry picked from commit e37ce56)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
vstinner added a commit that referenced this pull request Jun 2, 2026
)
gh-89554: Document _thread.LockType as a class (#150684)
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class. Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
(cherry picked from commit e37ce56)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@gaborbernat@vstinner@StanFromIreland