bpo-40724: Support setting buffer slots from type specs (GH-20648) (GH-20683)

This is not part of the limited API but makes the buffer slots available for type specs.
(cherry picked from commit f7c4e23642)
This commit is contained in:
Miss Islington (bot) 2020-06-07 00:06:40 -07:00 committed by GitHub
parent 90ee51f1cd
commit 1e4fa91104
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 2 deletions

View file

@ -476,6 +476,11 @@ class CAPITest(unittest.TestCase):
self.assertEqual(ref(), inst)
self.assertEqual(inst.weakreflist, ref)
def test_heaptype_with_buffer(self):
inst = _testcapi.HeapCTypeWithBuffer()
b = bytes(inst)
self.assertEqual(b, b"1234")
def test_c_subclass_of_heap_ctype_with_tpdealloc_decrefs_once(self):
subclass_instance = _testcapi.HeapCTypeSubclass()
type_refcnt = sys.getrefcount(_testcapi.HeapCTypeSubclass)