mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Better error message if stride used on normal sequence object
This commit is contained in:
parent
6ffd553899
commit
3b9c6677f8
1 changed files with 10 additions and 2 deletions
|
|
@ -2529,6 +2529,9 @@ call_function(func, arg, kw)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SLICE_ERROR_MSG \
|
||||||
|
"standard sequence type does not support step size other than one"
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
apply_subscript(v, w)
|
apply_subscript(v, w)
|
||||||
object *v, *w;
|
object *v, *w;
|
||||||
|
|
@ -2543,8 +2546,13 @@ apply_subscript(v, w)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
if (!is_intobject(w)) {
|
if (!is_intobject(w)) {
|
||||||
err_setstr(TypeError, "sequence subscript not int");
|
if (PySlice_Check(w)) {
|
||||||
|
err_setstr(ValueError, SLICE_ERROR_MSG);
|
||||||
|
} else {
|
||||||
|
err_setstr(TypeError,
|
||||||
|
"sequence subscript not int");
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
i = getintvalue(w);
|
i = getintvalue(w);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue