mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Bug #1379994: Fix *unicode_escape codecs to encode r'\' as r'\\'
just like string codecs.
This commit is contained in:
parent
e3547fd2f7
commit
835b243c71
3 changed files with 20 additions and 13 deletions
|
@ -1989,9 +1989,9 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
|
|||
while (size-- > 0) {
|
||||
Py_UNICODE ch = *s++;
|
||||
|
||||
/* Escape quotes */
|
||||
if (quotes &&
|
||||
(ch == (Py_UNICODE) PyString_AS_STRING(repr)[1] || ch == '\\')) {
|
||||
/* Escape quotes and backslashes */
|
||||
if ((quotes &&
|
||||
ch == (Py_UNICODE) PyString_AS_STRING(repr)[1]) || ch == '\\') {
|
||||
*p++ = '\\';
|
||||
*p++ = (char) ch;
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue