Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health fixes #2437

Merged
merged 8 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os
import sys
from . import Image, ImageFile
from ._binary import i32le as i32, o32le as o32
from ._binary import i32le as i32

__version__ = "0.5"

Expand Down Expand Up @@ -84,7 +84,6 @@ def Ghostscript(tile, size, fp, scale=1):
float((72.0 * size[1]) / (bbox[3]-bbox[1])))
# print("Ghostscript", scale, size, orig_size, bbox, orig_bbox, res)

import os
import subprocess
import tempfile

Expand Down
1 change: 0 additions & 1 deletion PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ def _save_netpbm(im, fp, filename):

import os
from subprocess import Popen, check_call, PIPE, CalledProcessError
import tempfile
file = im._dump()

with open(filename, 'wb') as f:
Expand Down
2 changes: 1 addition & 1 deletion PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import io
import warnings
from . import Image, ImageFile, TiffImagePlugin
from ._binary import i8, o8, i16be as i16, i32be as i32
from ._binary import i8, o8, i16be as i16
from .JpegPresets import presets
from ._util import isStringType

Expand Down
2 changes: 1 addition & 1 deletion PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import struct

from . import Image, ImageFile, ImagePalette
from ._binary import i8, i16be as i16, i32be as i32, o8, o16be as o16, o32be as o32
from ._binary import i8, i16be as i16, i32be as i32, o16be as o16, o32be as o32

__version__ = "0.9"

Expand Down
3 changes: 2 additions & 1 deletion PIL/SunImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class SunImageFile(ImageFile.ImageFile):

def _open(self):

# The Sun Raster file header is 32 bytes in length and has the following format:
# The Sun Raster file header is 32 bytes in length
# and has the following format:

# typedef struct _SunRaster
# {
Expand Down
2 changes: 1 addition & 1 deletion PIL/TgaImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


from . import Image, ImageFile, ImagePalette
from ._binary import i8, i16le as i16, o8, o16le as o16, o32le as o32
from ._binary import i8, i16le as i16, o8, o16le as o16

__version__ = "0.3"

Expand Down
2 changes: 1 addition & 1 deletion PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def _setup(self):
self.info["dpi"] = xres, yres
elif resunit == 3: # dots per centimeter. convert to dpi
self.info["dpi"] = xres * 2.54, yres * 2.54
elif resunit == None: # used to default to 1, but now 2)
elif resunit is None: # used to default to 1, but now 2)
self.info["dpi"] = xres, yres
# For backward compatibility, we also preserve the old behavior.
self.info["resolution"] = xres, yres
Expand Down
3 changes: 0 additions & 3 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def open_withImagemagick(self, f):

outfile = self.tempfile("temp.png")
if command_succeeds([IMCONVERT, f, outfile]):
from PIL import Image
return Image.open(outfile)
raise IOError()

Expand All @@ -179,7 +178,6 @@ def open_withImagemagick(self, f):

def fromstring(data):
from io import BytesIO
from PIL import Image
return Image.open(BytesIO(data))


Expand All @@ -191,7 +189,6 @@ def tostring(im, string_format, **options):


def hopper(mode=None, cache={}):
from PIL import Image
if mode is None:
# Always return fresh not-yet-loaded version of image.
# Operations on not-yet-loaded images is separate class of errors
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_fitsstub.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_load(self):
im = Image.open(TEST_FILE)

# Act / Assert: stub cannot load without an implemented handler
self.assertRaises(IOError, lambda: im.load())
self.assertRaises(IOError, im.load)

def test_save(self):
# Arrange
Expand Down
4 changes: 1 addition & 3 deletions Tests/test_file_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def check(colors, size, expected_palette_length):
check(256, 511, 256)

def test_optimize_full_l(self):
from io import BytesIO

im = Image.frombytes("L", (16, 16), bytes(bytearray(range(256))))
test_file = BytesIO()
im.save(test_file, "GIF", optimize=True)
Expand Down Expand Up @@ -425,7 +423,7 @@ def test_transparent_optimize(self):
reloaded = Image.open(out)

self.assertEqual(reloaded.info['transparency'], 253)


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_load(self):
im = Image.open(TEST_FILE)

# Act / Assert: stub cannot load without an implemented handler
self.assertRaises(IOError, lambda: im.load())
self.assertRaises(IOError, im.load)

def test_save(self):
# Arrange
Expand Down
8 changes: 4 additions & 4 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper, py3
from helper import unittest, PillowTestCase, hopper
from helper import djpeg_available, cjpeg_available

from io import BytesIO
Expand Down Expand Up @@ -32,11 +32,11 @@ def gen_random_image(self, size, mode='RGB'):
""" Generates a very hard to compress file
:param size: tuple
:param mode: optional image mode

"""
return Image.frombytes(mode, size,
os.urandom(size[0]*size[1]*len(mode)))

def test_sanity(self):

# internal version number
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_progressive_cmyk_buffer(self):
f = BytesIO()
im = self.gen_random_image((256,256), 'CMYK')
im.save(f, format='JPEG', progressive=True, quality=94)

def test_large_exif(self):
# https://github.com/python-pillow/Pillow/issues/148
f = self.tempfile('temp.jpg')
Expand Down
14 changes: 0 additions & 14 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,20 +564,6 @@ def test_save_tiff_with_jpegtables(self):
# Should not raise UnicodeDecodeError or anything else
im.save(outfile)

def test_page_number_x_0(self):
# Issue 973
# Test TIFF with tag 297 (Page Number) having value of 0 0.
# The first number is the current page number.
# The second is the total number of pages, zero means not available.
outfile = self.tempfile("temp.tif")
# Created by printing a page in Chrome to PDF, then:
# /usr/bin/gs -q -sDEVICE=tiffg3 -sOutputFile=total-pages-zero.tif
# -dNOPAUSE /tmp/test.pdf -c quit
infile = "Tests/images/total-pages-zero.tif"
im = Image.open(infile)
# Should not divide by zero
im.save(outfile)


if __name__ == '__main__':
unittest.main()
1 change: 0 additions & 1 deletion Tests/test_file_wmf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from helper import unittest, PillowTestCase
from PIL import Image
from io import BytesIO

class TestFileWmf(PillowTestCase):

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def create_test_image():
]
chans = []
bands = ImageMode.getmode(mode).bands
for band_ndx, band in enumerate(bands):
for band_ndx in range(len(bands)):
channel_type = 'L' # 8-bit unorm
channel_pattern = hopper(channel_type)

Expand Down
1 change: 0 additions & 1 deletion Tests/test_imagesequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def test_consecutive(self):
for frame in ImageSequence.Iterator(im):
if firstFrame is None:
firstFrame = frame.copy()
pass
for frame in ImageSequence.Iterator(im):
self.assert_image_equal(frame, firstFrame)
break
Expand Down