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

@ -1467,7 +1467,10 @@ idna_converter(PyObject *obj, struct maybe_idna *data)
len = PyByteArray_Size(obj);
}
else if (PyUnicode_Check(obj)) {
if (PyUnicode_READY(obj) == 0 && PyUnicode_IS_COMPACT_ASCII(obj)) {
if (PyUnicode_READY(obj) == -1) {
return 0;
}
if (PyUnicode_IS_COMPACT_ASCII(obj)) {
data->buf = PyUnicode_DATA(obj);
len = PyUnicode_GET_LENGTH(obj);
}