mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-05 13:43:28 +03:00
Merge pull request #6108 from radarhere/none
This commit is contained in:
commit
29960c6610
|
@ -154,14 +154,17 @@ class TestImageGetPixel(AccessTest):
|
||||||
|
|
||||||
# Check 0
|
# Check 0
|
||||||
im = Image.new(mode, (0, 0), None)
|
im = Image.new(mode, (0, 0), None)
|
||||||
with pytest.raises(IndexError):
|
assert im.load() is not None
|
||||||
|
|
||||||
|
error = ValueError if self._need_cffi_access else IndexError
|
||||||
|
with pytest.raises(error):
|
||||||
im.putpixel((0, 0), c)
|
im.putpixel((0, 0), c)
|
||||||
with pytest.raises(IndexError):
|
with pytest.raises(error):
|
||||||
im.getpixel((0, 0))
|
im.getpixel((0, 0))
|
||||||
# Check 0 negative index
|
# Check 0 negative index
|
||||||
with pytest.raises(IndexError):
|
with pytest.raises(error):
|
||||||
im.putpixel((-1, -1), c)
|
im.putpixel((-1, -1), c)
|
||||||
with pytest.raises(IndexError):
|
with pytest.raises(error):
|
||||||
im.getpixel((-1, -1))
|
im.getpixel((-1, -1))
|
||||||
|
|
||||||
# check initial color
|
# check initial color
|
||||||
|
@ -176,10 +179,10 @@ class TestImageGetPixel(AccessTest):
|
||||||
|
|
||||||
# Check 0
|
# Check 0
|
||||||
im = Image.new(mode, (0, 0), c)
|
im = Image.new(mode, (0, 0), c)
|
||||||
with pytest.raises(IndexError):
|
with pytest.raises(error):
|
||||||
im.getpixel((0, 0))
|
im.getpixel((0, 0))
|
||||||
# Check 0 negative index
|
# Check 0 negative index
|
||||||
with pytest.raises(IndexError):
|
with pytest.raises(error):
|
||||||
im.getpixel((-1, -1))
|
im.getpixel((-1, -1))
|
||||||
|
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
|
|
|
@ -304,7 +304,7 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
self.dispose = Image.core.fill(dispose_mode, dispose_size, color)
|
self.dispose = Image.core.fill(dispose_mode, dispose_size, color)
|
||||||
else:
|
else:
|
||||||
# replace with previous contents
|
# replace with previous contents
|
||||||
if self.im:
|
if self.im is not None:
|
||||||
# only dispose the extent in this frame
|
# only dispose the extent in this frame
|
||||||
self.dispose = self._crop(self.im, self.dispose_extent)
|
self.dispose = self._crop(self.im, self.dispose_extent)
|
||||||
elif frame_transparency is not None:
|
elif frame_transparency is not None:
|
||||||
|
|
|
@ -287,7 +287,7 @@ class IcnsImageFile(ImageFile.ImageFile):
|
||||||
)
|
)
|
||||||
|
|
||||||
px = Image.Image.load(self)
|
px = Image.Image.load(self)
|
||||||
if self.im and self.im.size == self.size:
|
if self.im is not None and self.im.size == self.size:
|
||||||
# Already loaded
|
# Already loaded
|
||||||
return px
|
return px
|
||||||
self.load_prepare()
|
self.load_prepare()
|
||||||
|
|
|
@ -304,7 +304,7 @@ class IcoImageFile(ImageFile.ImageFile):
|
||||||
self._size = value
|
self._size = value
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
if self.im and self.im.size == self.size:
|
if self.im is not None and self.im.size == self.size:
|
||||||
# Already loaded
|
# Already loaded
|
||||||
return Image.Image.load(self)
|
return Image.Image.load(self)
|
||||||
im = self.ico.getimage(self.size)
|
im = self.ico.getimage(self.size)
|
||||||
|
|
|
@ -847,7 +847,7 @@ class Image:
|
||||||
:returns: An image access object.
|
:returns: An image access object.
|
||||||
:rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess`
|
:rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess`
|
||||||
"""
|
"""
|
||||||
if self.im and self.palette and self.palette.dirty:
|
if self.im is not None and self.palette and self.palette.dirty:
|
||||||
# realize palette
|
# realize palette
|
||||||
mode, arr = self.palette.getdata()
|
mode, arr = self.palette.getdata()
|
||||||
self.im.putpalette(mode, arr)
|
self.im.putpalette(mode, arr)
|
||||||
|
@ -864,7 +864,7 @@ class Image:
|
||||||
self.palette.mode = palette_mode
|
self.palette.mode = palette_mode
|
||||||
self.palette.palette = self.im.getpalette(palette_mode, palette_mode)
|
self.palette.palette = self.im.getpalette(palette_mode, palette_mode)
|
||||||
|
|
||||||
if self.im:
|
if self.im is not None:
|
||||||
if cffi and USE_CFFI_ACCESS:
|
if cffi and USE_CFFI_ACCESS:
|
||||||
if self.pyaccess:
|
if self.pyaccess:
|
||||||
return self.pyaccess
|
return self.pyaccess
|
||||||
|
|
Loading…
Reference in New Issue
Block a user