bpo-31393: Fix the use of PyUnicode_READY(). (#3451)

This commit is contained in:
Serhiy Storchaka 2017-09-08 09:58:51 +03:00 committed by GitHub
parent 70c2dd306f
commit e3b2b4b8d9
5 changed files with 30 additions and 14 deletions

View file

@ -27,7 +27,7 @@ all_name_chars(PyObject *o)
};
const unsigned char *s, *e;
if (PyUnicode_READY(o) == -1 || !PyUnicode_IS_ASCII(o))
if (!PyUnicode_IS_ASCII(o))
return 0;
s = PyUnicode_1BYTE_DATA(o);
@ -63,6 +63,10 @@ intern_string_constants(PyObject *tuple)
for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
PyObject *v = PyTuple_GET_ITEM(tuple, i);
if (PyUnicode_CheckExact(v)) {
if (PyUnicode_READY(v) == -1) {
PyErr_Clear();
continue;
}
if (all_name_chars(v)) {
PyObject *w = v;
PyUnicode_InternInPlace(&v);