#27364: Deprecate invalid escape strings in str/byutes.

Patch by Emanuel Barry, reviewed by Serhiy Storchaka and Martin Panter.
This commit is contained in:
R David Murray 2016-09-08 15:34:08 -04:00
parent 186122ead2
commit 110b6fecbb
7 changed files with 48 additions and 12 deletions

View file

@ -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. */
}