mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
#27364: Deprecate invalid escape strings in str/byutes.
Patch by Emanuel Barry, reviewed by Serhiy Storchaka and Martin Panter.
This commit is contained in:
parent
186122ead2
commit
110b6fecbb
7 changed files with 48 additions and 12 deletions
|
|
@ -1207,8 +1207,9 @@ PyObject *PyBytes_DecodeEscape(const char *s,
|
|||
break;
|
||||
|
||||
default:
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "invalid escape sequence '\\%c'", *(--s)) < 0)
|
||||
goto failed;
|
||||
*p++ = '\\';
|
||||
s--;
|
||||
goto non_esc; /* an arbitrary number of unescaped
|
||||
UTF-8 bytes may follow. */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6065,6 +6065,9 @@ PyUnicode_DecodeUnicodeEscape(const char *s,
|
|||
goto error;
|
||||
|
||||
default:
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"invalid escape sequence '\\%c'", c) < 0)
|
||||
goto onError;
|
||||
WRITE_ASCII_CHAR('\\');
|
||||
WRITE_CHAR(c);
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue