summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c10
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);