summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2024-09-13 11:18:49 (GMT)
committerGitHub <noreply@github.com>2024-09-13 11:18:49 (GMT)
commit432bf31327c6b9647acb8bdb0eac2d392fd9f60a (patch)
treedf69d73f4e958d5bb84b7d032ae4c37a42e87d58 /Lib/test/test_capi
parentd7e83398c188a0acd19a496ee2eeeeab52d64a11 (diff)
downloadcpython-432bf31327c6b9647acb8bdb0eac2d392fd9f60a.zip
cpython-432bf31327c6b9647acb8bdb0eac2d392fd9f60a.tar.gz
cpython-432bf31327c6b9647acb8bdb0eac2d392fd9f60a.tar.bz2
gh-123909: PyType_From*: Disallow metaclasses with custom tp_new (GH-123947)
Diffstat (limited to 'Lib/test/test_capi')
-rw-r--r--Lib/test/test_capi/test_misc.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index d50217b..18392c4 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -722,22 +722,16 @@ class CAPITest(unittest.TestCase):
with self.assertRaisesRegex(TypeError, msg):
t = _testcapi.pytype_fromspec_meta(metaclass)
- def test_heaptype_with_custom_metaclass_deprecation(self):
+ def test_heaptype_base_with_custom_metaclass(self):
metaclass = _testcapi.HeapCTypeMetaclassCustomNew
- # gh-103968: a metaclass with custom tp_new is deprecated, but still
- # allowed for functions that existed in 3.11
- # (PyType_FromSpecWithBases is used here).
class Base(metaclass=metaclass):
pass
# Class creation from C
- with warnings_helper.check_warnings(
- ('.* _testcapi.Subclass .* custom tp_new.*in Python 3.14.*', DeprecationWarning),
- ):
+ msg = "Metaclasses with custom tp_new are not supported."
+ with self.assertRaisesRegex(TypeError, msg):
sub = _testcapi.make_type_with_base(Base)
- self.assertTrue(issubclass(sub, Base))
- self.assertIsInstance(sub, metaclass)
def test_multiple_inheritance_ctypes_with_weakref_or_dict(self):
for weakref_cls in (_testcapi.HeapCTypeWithWeakref,