mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
c_encoding can never be NULL, which allows some code simplification
This commit is contained in:
parent
7812dbccf0
commit
202803a0c0
1 changed files with 44 additions and 48 deletions
|
@ -4002,9 +4002,6 @@ decode_unicode(struct compiling *c, const char *s, size_t len, const char *encod
|
|||
char *p;
|
||||
const char *end;
|
||||
|
||||
if (encoding == NULL) {
|
||||
u = NULL;
|
||||
} else {
|
||||
/* check for integer overflow */
|
||||
if (len > PY_SIZE_MAX / 6)
|
||||
return NULL;
|
||||
|
@ -4050,7 +4047,7 @@ decode_unicode(struct compiling *c, const char *s, size_t len, const char *encod
|
|||
}
|
||||
len = p - buf;
|
||||
s = buf;
|
||||
}
|
||||
|
||||
v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
|
||||
Py_XDECREF(u);
|
||||
return v;
|
||||
|
@ -4994,8 +4991,7 @@ parsestr(struct compiling *c, const node *n, int *bytesmode, int *fmode)
|
|||
}
|
||||
}
|
||||
}
|
||||
need_encoding = (!*bytesmode && c->c_encoding != NULL &&
|
||||
strcmp(c->c_encoding, "utf-8") != 0);
|
||||
need_encoding = !*bytesmode && strcmp(c->c_encoding, "utf-8") != 0;
|
||||
if (rawmode || strchr(s, '\\') == NULL) {
|
||||
if (need_encoding) {
|
||||
PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue