mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
e4275f4df3
commit
16dcce2176
3 changed files with 5 additions and 4 deletions
|
@ -611,7 +611,7 @@ class CAPITest(unittest.TestCase):
|
||||||
|
|
||||||
# Class creation from C
|
# Class creation from C
|
||||||
with warnings_helper.check_warnings(
|
with warnings_helper.check_warnings(
|
||||||
('.*custom tp_new.*in Python 3.14.*', DeprecationWarning),
|
('.* _testcapi.Subclass .* custom tp_new.*in Python 3.14.*', DeprecationWarning),
|
||||||
):
|
):
|
||||||
sub = _testcapi.make_type_with_base(Base)
|
sub = _testcapi.make_type_with_base(Base)
|
||||||
self.assertTrue(issubclass(sub, Base))
|
self.assertTrue(issubclass(sub, Base))
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improve :exc:`DeprecationWarning` for uses of :c:type:`PyType_Spec` with metaclasses that have custom ``tp_new``.
|
|
@ -4264,9 +4264,9 @@ _PyType_FromMetaclass_impl(
|
||||||
if (_allow_tp_new) {
|
if (_allow_tp_new) {
|
||||||
if (PyErr_WarnFormat(
|
if (PyErr_WarnFormat(
|
||||||
PyExc_DeprecationWarning, 1,
|
PyExc_DeprecationWarning, 1,
|
||||||
"Using PyType_Spec with metaclasses that have custom "
|
"Type %s uses PyType_Spec with a metaclass that has custom "
|
||||||
"tp_new is deprecated and will no longer be allowed in "
|
"tp_new. This is deprecated and will no longer be allowed in "
|
||||||
"Python 3.14.") < 0) {
|
"Python 3.14.", spec->name) < 0) {
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue