Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3484,3 +3484,11 @@ def check_immutable_type(testcase, type):
regex = r'cannot set .* attribute of immutable type'
with testcase.assertRaisesRegex(TypeError, regex):
setattr(type, 'custom_attr', 123)

try:
from _testlimitedcapi import type_getflags, Py_TPFLAGS_IMMUTABLETYPE
except ImportError:
pass
else:
flags = type_getflags(type)
testcase.assertTrue(flags & Py_TPFLAGS_IMMUTABLETYPE)
Loading