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

@ -2137,8 +2137,7 @@ def test_signature(self): # gh-102029
]
for args, kwargs in arg_types:
with self.subTest(args=args, kwargs=kwargs):
with self.assertWarns(DeprecationWarning):
threading.RLock(*args, **kwargs)
self.assertRaises(TypeError, threading.RLock, *args, **kwargs)
# Subtypes with custom `__init__` are allowed (but, not recommended):
class CustomRLock(self.locktype):
@ -2156,6 +2155,9 @@ class ConditionAsRLockTests(lock_tests.RLockTests):
# Condition uses an RLock by default and exports its API.
locktype = staticmethod(threading.Condition)
def test_constructor_noargs(self):
self.skipTest("Condition allows positional arguments")
def test_recursion_count(self):
self.skipTest("Condition does not expose _recursion_count()")