8000 [3.12] gh-107810: Improve DeprecationWarning for metaclasses with cus… · python/cpython@431ce23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 431ce23

Browse files
miss-islingtoncdce8pEclips4
authored
[3.12] gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834) (#107864)
gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834) (cherry picked from commit 16dcce2) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
1 parent 585b4cc commit 431ce23

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
@@ -740,7 +740,7 @@ class Base(metaclass=metaclass):
740740

741741
# Class creation from C
742742
with warnings_helper.check_warnings(
743-
('.*custom tp_new.*in Python 3.14.*', DeprecationWarning),
743+
('.* _testcapi.Subclass .* custom tp_new.*in Python 3.14.*', DeprecationWarning),
744744
):
745745
sub = _testcapi.make_type_with_base(Base)
746746
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
@@ -4242,9 +4242,9 @@ _PyType_FromMetaclass_impl(
42424242
if (_allow_tp_new) {
42434243
if (PyErr_WarnFormat(
42444244
PyExc_DeprecationWarning, 1,
4245-
"Using PyType_Spec with metaclasses that have custom "
4246-
"tp_new is deprecated and will no longer be allowed in "
4247-
"Python 3.14.") < 0) {
4245+
"Type %s uses PyType_Spec with a metaclass that has custom "
4246+
"tp_new. This is deprecated and will no longer be allowed in "
4247+
"Python 3.14.", spec->name) < 0) {
42484248
goto finally;
42494249
}
42504250
}

0 commit comments

Comments
 (0)
0