diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-08 07:43:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 07:43:54 (GMT) |
commit | ddb536ba7b7c6022424e39d666c3cc81772645c0 (patch) | |
tree | 48ba8d3f97ac4b4b060c910db81cf48bb16ba896 /Objects/codeobject.c | |
parent | 9f2b3d4c2899f9caea2e47063061a76e460ac618 (diff) | |
download | cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.zip cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.gz cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.bz2 |
[3.6] bpo-31393: Fix the use of PyUnicode_READY(). (GH-3451). (#3453)
(cherry picked from commit e3b2b4b8d9e751b49e3550cb83ba39b54fdc377c)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 6de697a..d45be4c 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -22,8 +22,7 @@ all_name_chars(PyObject *o) static const unsigned char *name_chars = (unsigned char *)NAME_CHARS; const unsigned char *s, *e; - if (!PyUnicode_Check(o) || PyUnicode_READY(o) == -1 || - !PyUnicode_IS_ASCII(o)) + if (!PyUnicode_IS_ASCII(o)) return 0; if (ok_name_char[*name_chars] == 0) { @@ -64,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); |