Skip to content

Commit 518e57e

Browse files
committed
Add test for type creation with null new metaclass
1 parent b3cbd66 commit 518e57e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/test/test_descr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,15 @@ class X(C, int()):
815815
class X(int(), C):
816816
pass
817817

818+
@unittest.skipIf(_testcapi is None, 'need the _testcapi module')
819+
def test_type_with_null_new_metaclass(self):
820+
metaclass = _testcapi.HeapCTypeMetaclassNullNew
821+
base = _testcapi.pytype_fromspec_meta(metaclass)
822+
823+
# Exercise type_new's metaclass selection path, not a direct call.
824+
with self.assertRaisesRegex(TypeError, r"cannot create '.*' instances"):
825+
type("Derived", (base,), {})
826+
818827
def test_module_subclasses(self):
819828
# Testing Python subclass of module...
820829
log = []

0 commit comments

Comments
 (0)