diff options
author | Damien George <damien@micropython.org> | 2020-07-16 23:23:42 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-07-21 01:05:59 +1000 |
commit | a853fff838c1f995b9eeb0ebef5f117cfa3d5f0a (patch) | |
tree | a3787700c5911ea7ba9f3f18d43b0813224cecfe /tests/basics/memoryview_slice_assign.py | |
parent | 895b1dbdda132b115bb0b5102962f4f46adb7adb (diff) |
py/obj.h: Fix mp_seq_replace_slice_no_grow to use memmove not memcpy.
Because the argument arrays may overlap, as show by the new tests in this
commit.
Also remove the debugging comments for these macros, add a new comment
about overlapping regions, and separate the macros by blank lines to make
them easier to read.
Fixes issue #6244.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/basics/memoryview_slice_assign.py')
-rw-r--r-- | tests/basics/memoryview_slice_assign.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/basics/memoryview_slice_assign.py b/tests/basics/memoryview_slice_assign.py index b730dceba..74f6fae6f 100644 --- a/tests/basics/memoryview_slice_assign.py +++ b/tests/basics/memoryview_slice_assign.py @@ -61,3 +61,27 @@ try: memoryview(array.array('i'))[0:2] = b'1234' except ValueError: print('ValueError') + +# test shift left of bytearray +b = bytearray(range(10)) +mv = memoryview(b) +mv[1:] = mv[:-1] +print(b) + +# test shift right of bytearray +b = bytearray(range(10)) +mv = memoryview(b) +mv[:-1] = mv[1:] +print(b) + +# test shift left of array +a = array.array('I', range(10)) +mv = memoryview(a) +mv[1:] = mv[:-1] +print(a) + +# test shift right of array +a = array.array('I', range(10)) +mv = memoryview(a) +mv[:-1] = mv[1:] +print(a) |