gh-134087: enforce signature of threading.RLock (#134178)

- Reject positional and keyword arguments in `_thread.RLock.__new__`.
- Convert `_thread.lock.__new__` to AC.
This commit is contained in:
Bénédikt Tran 2025-05-19 11:26:14 +02:00 committed by GitHub
parent 9983c7d441
commit d6dc33ed80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 115 additions and 53 deletions

View file

@ -123,7 +123,7 @@ def gettrace():
Lock = _LockType
def RLock(*args, **kwargs):
def RLock():
"""Factory function that returns a new reentrant lock.
A reentrant lock must be released by the thread that acquired it. Once a
@ -132,16 +132,9 @@ def RLock(*args, **kwargs):
acquired it.
"""
if args or kwargs:
import warnings
warnings.warn(
'Passing arguments to RLock is deprecated and will be removed in 3.15',
DeprecationWarning,
stacklevel=2,
)
if _CRLock is None:
return _PyRLock(*args, **kwargs)
return _CRLock(*args, **kwargs)
return _PyRLock()
return _CRLock()
class _RLock:
"""This class implements reentrant lock objects.