diff options
| author | Paul Sokolovsky | 2014-05-25 02:29:40 +0300 |
|---|---|---|
| committer | Paul Sokolovsky | 2014-05-25 02:29:40 +0300 |
| commit | 69d081a7cf7e0ae1e815365af8b3c19be293da84 (patch) | |
| tree | 7a423dd4da8fc839469a53cfa42af41a044a5806 /py/sequence.c | |
| parent | afaaf535e6cfaf599432b13a2fbe9373e6a2c4b8 (diff) | |
py: Handle case of slice start > stop in common sequence function.
Diffstat (limited to 'py/sequence.c')
| -rw-r--r-- | py/sequence.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/sequence.c b/py/sequence.c index 2c1f6a836..0a4bb26b3 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -88,6 +88,12 @@ bool mp_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_u } else if (stop > len) { stop = len; } + + // CPython returns empty sequence in such case, or point for assignment is at start + if (start > stop) { + stop = start; + } + *begin = start; *end = stop; return true; |
