File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
graalpython/com.oracle.graal.python.test/src/tests Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 3
3
#
4
4
# Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5
5
6
+ import sys
7
+ import pytest
6
8
7
9
def test_subscript ():
8
10
v = memoryview (b'abcefg' )
@@ -162,3 +164,21 @@ def test_pack():
162
164
assert b == b'\x01 '
163
165
memoryview (b ).cast ('?' )[0 ] = False
164
166
assert b == b'\x00 '
167
+
168
+ def test_read_after_resize ():
169
+ if sys .implementation .name != "graalpython" :
170
+ return
171
+ # CPython prevents resizing of acquired buffers at all to avoid a segfault
172
+ # We don't want to impose locking on managed objects because we cannot automatically
173
+ # release the lock by reference counting. Check that we don't hard crash when
174
+ # does an out-of-bound read on a resized buffer
175
+ b = bytearray (b'12341251452134523463456435643' )
176
+ m = memoryview (b )
177
+ assert m [1 ] == ord ('2' )
178
+ b .clear ()
179
+ with pytest .raises (IndexError ):
180
+ print (m [1 ])
181
+ with pytest .raises (IndexError ):
182
+ m [1 ] = 3
183
+ with pytest .raises (IndexError ):
184
+ print (m .tobytes ())
You can’t perform that action at this time.
0 commit comments