gh-117657: Fix __slots__ thread safety in free-threaded build (#119368)

Fix a race in `PyMember_GetOne` and `PyMember_SetOne` for `Py_T_OBJECT_EX`.
These functions implement `__slots__` accesses for Python objects.
This commit is contained in:
Daniele Parmeggiani 2024-06-17 14:44:54 -04:00 committed by GitHub
parent 460cc9e14e
commit 362cd2680b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 77 additions and 12 deletions

View file

@ -1314,7 +1314,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
# Inherit from object on purpose to check some backwards compatibility paths
class X(object):
__slots__ = "a"
with self.assertRaisesRegex(AttributeError, "'X' object has no attribute 'a'"):
with self.assertRaisesRegex(AttributeError, "'test.test_descr.ClassPropertiesAndMethods.test_slots.<locals>.X' object has no attribute 'a'"):
X().a
# Test string subclass in `__slots__`, see gh-98783