mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-39960: Allow heap types in the "Carlo Verre" hack check that override "tp_setattro()" (GH-21092)
Automerge-Triggered-By: @gvanrossum
(cherry picked from commit 148f329135
)
Co-authored-by: scoder <stefan_ml@behnel.de>
This commit is contained in:
parent
32e9e17c42
commit
bfec674254
4 changed files with 120 additions and 11 deletions
|
@ -515,6 +515,14 @@ class CAPITest(unittest.TestCase):
|
|||
# Test that subtype_dealloc decref the newly assigned __class__ only once
|
||||
self.assertEqual(new_type_refcnt, sys.getrefcount(_testcapi.HeapCTypeSubclass))
|
||||
|
||||
def test_heaptype_with_setattro(self):
|
||||
obj = _testcapi.HeapCTypeSetattr()
|
||||
self.assertEqual(obj.pvalue, 10)
|
||||
obj.value = 12
|
||||
self.assertEqual(obj.pvalue, 12)
|
||||
del obj.value
|
||||
self.assertEqual(obj.pvalue, 0)
|
||||
|
||||
def test_pynumber_tobase(self):
|
||||
from _testcapi import pynumber_tobase
|
||||
self.assertEqual(pynumber_tobase(123, 2), '0b1111011')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue