summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-07-30 18:40:29 (GMT)
committerGuido van Rossum <guido@python.org>1996-07-30 18:40:29 (GMT)
commit3b9c6677f883659c780b4b5099e1ea42c7b87642 (patch)
treec7008b28ff00c398800b766c8cd6496e8f62b870
parent6ffd55389914b299b1a03be2091744b9411c926e (diff)
downloadcpython-3b9c6677f883659c780b4b5099e1ea42c7b87642.zip
cpython-3b9c6677f883659c780b4b5099e1ea42c7b87642.tar.gz
cpython-3b9c6677f883659c780b4b5099e1ea42c7b87642.tar.bz2
Better error message if stride used on normal sequence object
-rw-r--r--Python/ceval.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index d526095..36e9b8c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2529,6 +2529,9 @@ call_function(func, arg, kw)
return result;
}
+#define SLICE_ERROR_MSG \
+ "standard sequence type does not support step size other than one"
+
static object *
apply_subscript(v, w)
object *v, *w;
@@ -2543,8 +2546,13 @@ apply_subscript(v, w)
}
else {
int i;
- if (!is_intobject(w)) {
- err_setstr(TypeError, "sequence subscript not int");
+ if (!is_intobject(w)) {
+ if (PySlice_Check(w)) {
+ err_setstr(ValueError, SLICE_ERROR_MSG);
+ } else {
+ err_setstr(TypeError,
+ "sequence subscript not int");
+ }
return NULL;
}
i = getintvalue(w);