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