summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 0983651..cea503e 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4689,7 +4689,7 @@ ext_call_fail:
int
_PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi)
{
- if (v != NULL) {
+ if (v != NULL && v != Py_None) {
Py_ssize_t x;
if (PyInt_Check(v)) {
/* XXX(nnorwitz): I think PyInt_AS_LONG is correct,
@@ -4714,6 +4714,26 @@ _PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi)
return 1;
}
+int
+_PyEval_SliceIndexNotNone(PyObject *v, Py_ssize_t *pi)
+{
+ Py_ssize_t x;
+ if (PyIndex_Check(v)) {
+ x = PyNumber_AsSsize_t(v, NULL);
+ if (x == -1 && PyErr_Occurred())
+ return 0;
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "slice indices must be integers or "
+ "have an __index__ method");
+ return 0;
+ }
+ *pi = x;
+ return 1;
+}
+
+
#undef ISINDEX
#define ISINDEX(x) ((x) == NULL || \
PyInt_Check(x) || PyLong_Check(x) || PyIndex_Check(x))