Merge pull request #1903 from radarhere/health

Landscape health fixes
This commit is contained in:
Hugo 2016-05-10 17:36:48 +03:00
commit 55e70da265
8 changed files with 21 additions and 21 deletions

View File

@ -399,7 +399,7 @@ def _fixup_dict(src_dict):
# returns a dict with any single item tuples/lists as individual values
def _fixup(value):
try:
if len(value) == 1 and type(value) != type({}):
if len(value) == 1 and not isinstance(value, dict):
return value[0]
except: pass
return value

View File

@ -1119,18 +1119,19 @@ class TiffImageFile(ImageFile.ImageFile):
if DEBUG:
print("- size:", self.size)
format = self.tag_v2.get(SAMPLEFORMAT, (1,))
if len(format) > 1 and max(format) == min(format) == 1:
sampleFormat = self.tag_v2.get(SAMPLEFORMAT, (1,))
if (len(sampleFormat) > 1
and max(sampleFormat) == min(sampleFormat) == 1):
# SAMPLEFORMAT is properly per band, so an RGB image will
# be (1,1,1). But, we don't support per band pixel types,
# and anything more than one band is a uint8. So, just
# take the first element. Revisit this if adding support
# for more exotic images.
format = (1,)
sampleFormat = (1,)
# mode: check photometric interpretation and bits per pixel
key = (
self.tag_v2.prefix, photo, format, fillorder,
self.tag_v2.prefix, photo, sampleFormat, fillorder,
self.tag_v2.get(BITSPERSAMPLE, (1,)),
self.tag_v2.get(EXTRASAMPLES, ())
)
@ -1215,7 +1216,7 @@ class TiffImageFile(ImageFile.ImageFile):
# https://github.com/python-pillow/Pillow/issues/279
if fillorder == 2:
key = (
self.tag_v2.prefix, photo, format, 1,
self.tag_v2.prefix, photo, sampleFormat, 1,
self.tag_v2.get(BITSPERSAMPLE, (1,)),
self.tag_v2.get(EXTRASAMPLES, ())
)

View File

@ -39,7 +39,7 @@ class Enhance(Frame):
s.pack()
def update(self, value):
self.value = eval(value)
self.value = float(value)
self.tkim.paste(self.enhancer.enhance(self.value))
#

View File

@ -208,9 +208,9 @@ class PILDriver(object):
Process the top image with the given filter.
"""
from PIL import ImageFilter
filter = eval("ImageFilter." + self.do_pop().upper())
imageFilter = getattr(ImageFilter, self.do_pop().upper())
image = self.do_pop()
self.push(image.filter(filter))
self.push(image.filter(imageFilter))
def do_getbbox(self):
"""usage: getbbox

View File

@ -42,7 +42,7 @@ class UI(Frame):
# self.redraw()
def update_scale(self, value):
self.value = eval(value)
self.value = float(value)
self.redraw()

View File

@ -251,8 +251,8 @@ class TestFileTiff(PillowTestCase):
filename = "Tests/images/pil136.tiff"
im = Image.open(filename)
self.assert_warning(DeprecationWarning, lambda: im.tag_v2.as_dict())
self.assert_warning(DeprecationWarning, lambda: im.tag.as_dict())
self.assert_warning(DeprecationWarning, im.tag_v2.as_dict)
self.assert_warning(DeprecationWarning, im.tag.as_dict)
def test_dict(self):
# Arrange

View File

@ -66,7 +66,7 @@ class TestImagePath(PillowTestCase):
try:
# post patch, this fails with a memory error
x = evil()
# This fails due to the invalid malloc above,
# and segfaults
for i in range(200000):
@ -85,15 +85,15 @@ class TestImagePath(PillowTestCase):
class evil:
def __init__(self):
self.corrupt = Image.core.path(0x4000000000000000)
def __init__(self):
self.corrupt = Image.core.path(0x4000000000000000)
def __getitem__(self, i):
x = self.corrupt[i]
return struct.pack("dd", x[0], x[1])
def __getitem__(self, i):
x = self.corrupt[i]
return struct.pack("dd", x[0], x[1])
def __setitem__(self, i, x):
self.corrupt[i] = struct.unpack("dd", x)
def __setitem__(self, i, x):
self.corrupt[i] = struct.unpack("dd", x)
if __name__ == '__main__':

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python
import nose
import os
import sys
import glob