mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #9425: Create PyErr_WarnFormat() function
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning message. Strip also some trailing spaces.
This commit is contained in:
parent
b4b8eb9163
commit
4a2b7a1b14
7 changed files with 74 additions and 34 deletions
|
|
@ -3892,13 +3892,10 @@ PyType_Ready(PyTypeObject *type)
|
|||
tp_reserved) but not tp_richcompare. */
|
||||
if (type->tp_reserved && !type->tp_richcompare) {
|
||||
int error;
|
||||
char msg[240];
|
||||
PyOS_snprintf(msg, sizeof(msg),
|
||||
"Type %.100s defines tp_reserved (formerly "
|
||||
"tp_compare) but not tp_richcompare. "
|
||||
"Comparisons may not behave as intended.",
|
||||
type->tp_name);
|
||||
error = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1);
|
||||
error = PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"Type %.100s defines tp_reserved (formerly tp_compare) "
|
||||
"but not tp_richcompare. Comparisons may not behave as intended.",
|
||||
type->tp_name);
|
||||
if (error == -1)
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue