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

@ -124,6 +124,11 @@ class BaseLockTests(BaseTestCase):
lock = self.locktype()
del lock
def test_constructor_noargs(self):
self.assertRaises(TypeError, self.locktype, 1)
self.assertRaises(TypeError, self.locktype, x=1)
self.assertRaises(TypeError, self.locktype, 1, x=2)
def test_repr(self):
lock = self.locktype()
self.assertRegex(repr(lock), "<unlocked .* object (.*)?at .*>")