summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2017-09-15 01:13:16 (GMT)
committerGitHub <noreply@github.com>2017-09-15 01:13:16 (GMT)
commitb2e5794870eb4728ddfaafc0f79a40299576434f (patch)
treeb625687bc81fd33c04fd83820e1276db92d9fa1a /Objects/dictobject.c
parentd384a81f557dab0b142bfcc9850bc68df46496ef (diff)
downloadcpython-b2e5794870eb4728ddfaafc0f79a40299576434f.zip
cpython-b2e5794870eb4728ddfaafc0f79a40299576434f.tar.gz
cpython-b2e5794870eb4728ddfaafc0f79a40299576434f.tar.bz2
bpo-31338 (#3374)
* Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 81c7f7f..6ba2cc9 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -643,8 +643,7 @@ lookdict_index(PyDictKeysObject *k, Py_hash_t hash, Py_ssize_t index)
perturb >>= PERTURB_SHIFT;
i = mask & (i*5 + perturb + 1);
}
- assert(0); /* NOT REACHED */
- return DKIX_ERROR;
+ Py_UNREACHABLE();
}
/*
@@ -723,8 +722,7 @@ top:
perturb >>= PERTURB_SHIFT;
i = (i*5 + perturb + 1) & mask;
}
- assert(0); /* NOT REACHED */
- return 0;
+ Py_UNREACHABLE();
}
/* Specialized version for string-only keys */
@@ -766,9 +764,7 @@ lookdict_unicode(PyDictObject *mp, PyObject *key,
perturb >>= PERTURB_SHIFT;
i = mask & (i*5 + perturb + 1);
}
-
- assert(0); /* NOT REACHED */
- return 0;
+ Py_UNREACHABLE();
}
/* Faster version of lookdict_unicode when it is known that no <dummy> keys
@@ -810,8 +806,7 @@ lookdict_unicode_nodummy(PyDictObject *mp, PyObject *key,
perturb >>= PERTURB_SHIFT;
i = mask & (i*5 + perturb + 1);
}
- assert(0); /* NOT REACHED */
- return 0;
+ Py_UNREACHABLE();
}
/* Version of lookdict for split tables.
@@ -856,8 +851,7 @@ lookdict_split(PyDictObject *mp, PyObject *key,
perturb >>= PERTURB_SHIFT;
i = mask & (i*5 + perturb + 1);
}
- assert(0); /* NOT REACHED */
- return 0;
+ Py_UNREACHABLE();
}
int
@@ -3603,7 +3597,7 @@ dictiter_reduce(dictiterobject *di)
else if (Py_TYPE(di) == &PyDictIterValue_Type)
element = dictiter_iternextvalue(&tmp);
else
- assert(0);
+ Py_UNREACHABLE();
if (element) {
if (PyList_Append(list, element)) {
Py_DECREF(element);