Skip to content

gh-137808: use argument clinic for _thread.lock and _thread.RLock #137809

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

Merged
merged 5 commits into from
Aug 15, 2025

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Aug 15, 2025

@serhiy-storchaka
Copy link
Member

I am surprised that this change did not affect test_inspec test for _thread signatures. Could you please show the diff for the pydoc output for _thread?

@kumaraditya303
Copy link
Contributor Author

Could you please show the diff for the pydoc output for _thread?

41c41
<      |  __exit__(self, /, *exc_info)
---
>      |  __exit__(self, exc_type=None, exc_value=None, exc_tb=None, /)
48c48,50
<      |      Lock the lock.  Without argument, this blocks if the lock is already
---
>      |      Lock the lock.
>      |
>      |      Without argument, this blocks if the lock is already
65c67,69
<      |      Release the lock, allowing another thread that is blocked waiting for
---
>      |      Release the lock.
>      |
>      |      Allows another thread that is blocked waiting for
84c88
<      |  __exit__(self, /, *exc_info)
---
>      |  __exit__(self, exc_type=None, exc_value=None, exc_tb=None, /)
91c95,97
<      |      Lock the lock.  `blocking` indicates whether we should wait
---
>      |      Lock the lock.
>      |
>      |      `blocking` indicates whether we should wait
105,106d110
<      |      locked()
<      |
110c114,116
<      |      Release the lock, allowing another thread that is blocked waiting for
---
>      |      Release the lock.
>      |
>      |      Allows another thread that is blocked waiting for
142c148
<      |  __exit__(self, /, *exc_info)
---
>      |  __exit__(self, exc_type=None, exc_value=None, exc_tb=None, /)
149c155,157
<      |      Lock the lock.  Without argument, this blocks if the lock is already
---
>      |      Lock the lock.
>      |
>      |      Without argument, this blocks if the lock is already
166c174,176
<      |      Release the lock, allowing another thread that is blocked waiting for
---
>      |      Release the lock.
>      |
>      |      Allows another thread that is blocked waiting for

@serhiy-storchaka
Copy link
Member

What about the acquire() methods? Should not they now have machine readable signatures?

Oh, and pydoc does not show proivate methods for module and class, you need to do direct request for _thread.RLock._acquire_restore.

@kumaraditya303
Copy link
Contributor Author

What about the acquire() methods? Should not they now have machine readable signatures?

Help on method descriptor acquire in _thread.RLock:

_thread.RLock.acquire = acquire(self, /, blocking=True, timeout=-1) unbound _thread.RLock method
    Lock the lock.

Help on method descriptor acquire in _thread.lock:

_thread.lock.acquire = acquire(self, /, blocking=True, timeout=-1) unbound _thread.lock method
    Lock the lock.

The signatures looks fine to me for acquire methods, what do you mean by "machine readable signatures"? are these two signatures incorrect?

@serhiy-storchaka
Copy link
Member

Aha, this is because signatures were already encoded in the docstrings! Now Argument Clinic will generate identical signatures, this is why there was not difference in the pydoc output.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

LGTM as well

@kumaraditya303 kumaraditya303 linked an issue Aug 15, 2025 that may be closed by this pull request
@kumaraditya303 kumaraditya303 enabled auto-merge (squash) August 15, 2025 13:57
@kumaraditya303 kumaraditya303 merged commit 31bbea1 into python:main Aug 15, 2025
46 checks passed
@kumaraditya303 kumaraditya303 deleted the lock branch August 15, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use argument clinic for _thread.lock and _thread.RLock
4 participants