]> granicus.if.org Git - python/commitdiff
Better error message if stride used on normal sequence object
authorGuido van Rossum <guido@python.org>
Tue, 30 Jul 1996 18:40:29 +0000 (18:40 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Jul 1996 18:40:29 +0000 (18:40 +0000)
Python/ceval.c

index d526095161042fdd499f39093c89498355092859..36e9b8c8eb65c9a8870b0e12f00f0216f898fe40 100644 (file)
@@ -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);