gh-128016: Improved invalid escape sequence warning message (#128020)

This commit is contained in:
Umar Butler 2025-01-16 04:00:54 +11:00 committed by GitHub
parent 40a4d88a14
commit 8d8b854824
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 63 additions and 25 deletions

View file

@ -6853,7 +6853,8 @@ _PyUnicode_DecodeUnicodeEscapeStateful(const char *s,
unsigned char c = *first_invalid_escape;
if ('4' <= c && c <= '7') {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"invalid octal escape sequence '\\%.3s'",
"\"\\%.3s\" is an invalid octal escape sequence. "
"Such sequences will not work in the future. ",
first_invalid_escape) < 0)
{
Py_DECREF(result);
@ -6862,7 +6863,8 @@ _PyUnicode_DecodeUnicodeEscapeStateful(const char *s,
}
else {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"invalid escape sequence '\\%c'",
"\"\\%c\" is an invalid escape sequence. "
"Such sequences will not work in the future. ",
c) < 0)
{
Py_DECREF(result);