8000 gh-107810: Improve DeprecationWarning for metaclasses with custom tp_… · python/cpython@16dcce2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16dcce2

Browse files
cdce8pEclips4
andauthored
gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
1 parent e4275f4 commit 16dcce2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Lib/test/test_capi/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ class Base(metaclass=metaclass):
611611

612612
# Class creation from C
613613
with warnings_helper.check_warnings(
614-
('.*custom tp_new.*in Python 3.14.*', DeprecationWarning),
614+
('.* _testcapi.Subclass .* custom tp_new.*in Python 3.14.*', DeprecationWarning),
615615
):
616616
sub = _testcapi.make_type_with_base(Base)
617617
self.assertTrue(issubclass(sub, Base))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve :exc:`DeprecationWarning` for uses of :c:type:`PyType_Spec` with metaclasses that have custom ``tp_new``.

Objects/typeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,9 +4264,9 @@ _PyType_FromMetaclass_impl(
42644264
if (_allow_tp_new) {
42654265
if (PyErr_WarnFormat(
42664266
PyExc_DeprecationWarning, 1,
4267-
"Using PyType_Spec with metaclasses that have custom "
4268-
"tp_new is deprecated and will no longer be allowed in "
4269-
"Python 3.14.") < 0) {
4267+
"Type %s uses PyType_Spec with a metaclass that has custom "
4268+
"tp_new. This is deprecated and will no longer be allowed in "
4269+
"Python 3.14.", spec->name) < 0) {
42704270
goto finally;
42714271
}
42724272
}

0 commit comments

Comments
 (0)
0