mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
bpo-31393: Fix the use of PyUnicode_READY(). (#3451)
This commit is contained in:
parent
70c2dd306f
commit
e3b2b4b8d9
5 changed files with 30 additions and 14 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue