diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-04-19 05:28:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-19 05:28:04 (GMT) |
commit | b7e1eff8436f6e0c4aac440036092fcf96f82960 (patch) | |
tree | 00c634897d754dae08e0252cdc936fa093bab3c2 /Python | |
parent | 9009f3e389123c5f94d4d12f1f51b0a88531c37c (diff) | |
download | cpython-b7e1eff8436f6e0c4aac440036092fcf96f82960.zip cpython-b7e1eff8436f6e0c4aac440036092fcf96f82960.tar.gz cpython-b7e1eff8436f6e0c4aac440036092fcf96f82960.tar.bz2 |
bpo-33299: Return an object itself for some types in _PyCode_ConstantKey(). (GH-6513)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c index 62fe971..6053db2 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5299,10 +5299,12 @@ dict_keys_inorder(PyObject *dict, Py_ssize_t offset) return NULL; while (PyDict_Next(dict, &pos, &k, &v)) { i = PyLong_AS_LONG(v); - /* The keys of the dictionary are tuples. (see compiler_add_o - * and _PyCode_ConstantKey). The object we want is always second, - * though. */ - k = PyTuple_GET_ITEM(k, 1); + /* The keys of the dictionary can be tuples wrapping a contant. + * (see compiler_add_o and _PyCode_ConstantKey). In that case + * the object we want is always second. */ + if (PyTuple_CheckExact(k)) { + k = PyTuple_GET_ITEM(k, 1); + } Py_INCREF(k); assert((i - offset) < size); assert((i - offset) >= 0); |