Skip to content

Commit a7a8dc9

Browse files
committed
gh-155503: Check Py_TPFLAGS_IMMUTABLETYPE in check_immutable_type()
Check for Py_TPFLAGS_IMMUTABLETYPE type flag in test.support.check_immutable_type().
1 parent 29837a9 commit a7a8dc9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,3 +3484,11 @@ def check_immutable_type(testcase, type):
34843484
regex = r'cannot set .* attribute of immutable type'
34853485
with testcase.assertRaisesRegex(TypeError, regex):
34863486
setattr(type, 'custom_attr', 123)
3487+
3488+
try:
3489+
from _testlimitedcapi import type_getflags, Py_TPFLAGS_IMMUTABLETYPE
3490+
except ImportError:
3491+
pass
3492+
else:
3493+
flags = type_getflags(type)
3494+
testcase.assertTrue(flags & Py_TPFLAGS_IMMUTABLETYPE)

0 commit comments

Comments
 (0)