mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
GH-95245: Move weakreflist into the pre-header. (GH-95996)
This commit is contained in:
parent
829aab8592
commit
5a8c15819c
6 changed files with 105 additions and 20 deletions
|
|
@ -579,6 +579,37 @@ def test_heaptype_with_weakref(self):
|
|||
self.assertEqual(ref(), inst)
|
||||
self.assertEqual(inst.weakreflist, ref)
|
||||
|
||||
def test_heaptype_with_managed_weakref(self):
|
||||
inst = _testcapi.HeapCTypeWithManagedWeakref()
|
||||
ref = weakref.ref(inst)
|
||||
self.assertEqual(ref(), inst)
|
||||
|
||||
def test_sublclassing_managed_weakref(self):
|
||||
|
||||
class C(_testcapi.HeapCTypeWithManagedWeakref):
|
||||
pass
|
||||
|
||||
inst = C()
|
||||
ref = weakref.ref(inst)
|
||||
self.assertEqual(ref(), inst)
|
||||
|
||||
def test_sublclassing_managed_both(self):
|
||||
|
||||
class C1(_testcapi.HeapCTypeWithManagedWeakref, _testcapi.HeapCTypeWithManagedDict):
|
||||
pass
|
||||
|
||||
class C2(_testcapi.HeapCTypeWithManagedDict, _testcapi.HeapCTypeWithManagedWeakref):
|
||||
pass
|
||||
|
||||
for cls in (C1, C2):
|
||||
inst = cls()
|
||||
ref = weakref.ref(inst)
|
||||
self.assertEqual(ref(), inst)
|
||||
inst.spam = inst
|
||||
del inst
|
||||
ref = weakref.ref(cls())
|
||||
self.assertIs(ref(), None)
|
||||
|
||||
def test_heaptype_with_buffer(self):
|
||||
inst = _testcapi.HeapCTypeWithBuffer()
|
||||
b = bytes(inst)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue