Skip to content

gh-152798: update sys.thread_info.lock documentation t match implemen…#153263

Merged
kumaraditya303 merged 3 commits into
python:mainfrom
Wojusensei:fix-thread-info
Jul 7, 2026
Merged

gh-152798: update sys.thread_info.lock documentation t match implemen…#153263
kumaraditya303 merged 3 commits into
python:mainfrom
Wojusensei:fix-thread-info

Conversation

@Wojusensei

Copy link
Copy Markdown
Contributor

this PR updates the documentation for “sys.thread_info.lock” to reflect what the code actually returns today

the code currently returns "pymutex" on POSIX platforms ( except Windows and WASI, where it returns None ), but the docs still described the old "semaphore" and "mutex+cond" values

as discussed in the issue the consensus is that it's too late to change the code behavior, but the documentation should be corrected to avoid confusion

(no code changes are made here and only docs)

Closes gh-152798.

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jul 7, 2026
@python-cla-bot

python-cla-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community

read-the-docs-community Bot commented Jul 7, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33481366 | 📁 Comparing 05c53e5 against main (2cd5b79)

  🔍 Preview build  

1 file changed
± library/sys.html

Comment thread Doc/library/sys.rst Outdated
* ``"mutex+cond"``: a lock uses a mutex and a condition variable
* ``None`` if this information is unknown
* ``"pymutex"``: a lock uses the PyMutex implementation
* ``None`` if the lock implementation is not exposed (e.g. : on Windows and WASI)

@vstinner vstinner Jul 7, 2026

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.

Please keep semaphore and mutex+cond in the documentation. It's useful to understand Python 3.14 and older values.

The lock is not None on Windows, but pymutex. Example from test.pythoninfo: https://buildbot.python.org/#/builders/1620/builds/3968

sys.thread_info: sys.thread_info(name='nt', lock='pymutex', version=None)

I also see pymutex on a WASI buildbot: https://buildbot.python.org/#/builders/1046/builds/12356

sys.thread_info: sys.thread_info(name='pthread', lock='pymutex', version=None)

Same on Emscripten: https://buildbot.python.org/#/builders/1810/builds/3145

sys.thread_info: sys.thread_info(name='pthread-stubs', lock='pymutex', version=None)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for the details and i've kept the historical values and removed the incorrect None on Windows / WASI mention.
and now it reflects that pymutex is used across all platforms from 3.15 onward. PTAL.

Comment thread Doc/library/sys.rst Outdated
* ``"mutex+cond"``: a lock uses a mutex and a condition variable
* ``"semaphore"``: a lock uses a semaphore (Python 3.14 and older)
* ``"mutex+cond"``: a lock uses a mutex and a condition variable (Python 3.14 and older)
* ``"pymutex"``: a lock uses the PyMutex implementation (Python 3.15 and newer)

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.

We should link to :c:type:`PyMutex` here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i added :c:type: link to PyMutex just as suggested

@vstinner vstinner 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

@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 7, 2026
@kumaraditya303 kumaraditya303 merged commit 48cc257 into python:main Jul 7, 2026
37 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jul 7, 2026
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Jul 7, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

sys.thread_info.lock was changed to "pymutex" in 3.15, even though _thread.Lock had already switched to PyMutex in 3.14 and 3.13.1

4 participants