File tree Expand file tree Collapse file tree 1 file changed +2
-29
lines changed
Expand file tree Collapse file tree 1 file changed +2
-29
lines changed Original file line number Diff line number Diff line change 1- import sys
2-
31import pytest
42
53from PIL import Image
64
7- from .helper import is_win32
8-
9- pytestmark = pytest .mark .skipif (is_win32 (), reason = "Win32 does not call map_buffer" )
10-
11-
12- def test_overflow ():
13- # There is the potential to overflow comparisons in map.c
14- # if there are > SIZE_MAX bytes in the image or if
15- # the file encodes an offset that makes
16- # (offset + size(bytes)) > SIZE_MAX
17-
18- # Note that this image triggers the decompression bomb warning:
19- max_pixels = Image .MAX_IMAGE_PIXELS
20- Image .MAX_IMAGE_PIXELS = None
215
22- # This image hits the offset test.
6+ def test_tobytes ():
237 with Image .open ("Tests/images/l2rgb_read.bmp" ) as im :
248 with pytest .raises ((ValueError , MemoryError , OSError )):
25- im .load ()
26-
27- Image .MAX_IMAGE_PIXELS = max_pixels
28-
29-
30- @pytest .mark .skipif (sys .maxsize <= 2 ** 32 , reason = "Requires 64-bit system" )
31- def test_ysize ():
32- numpy = pytest .importorskip ("numpy" , reason = "NumPy not installed" )
33-
34- # Should not raise 'Integer overflow in ysize'
35- arr = numpy .zeros ((46341 , 46341 ), dtype = numpy .uint8 )
36- Image .fromarray (arr )
9+ im .tobytes ()
You can’t perform that action at this time.
0 commit comments