Skip to content

Commit

Permalink
Merge pull request #1566 from radarhere/health
Browse files Browse the repository at this point in the history
Health fixes
  • Loading branch information
hugovk committed Dec 2, 2015
2 parents 6604706 + 806df2e commit c32a825
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def Ghostscript(tile, size, fp, scale=1):
os.unlink(outfile)
if infile_temp:
os.unlink(infile_temp)
except:
except OSError:
pass

return im
Expand Down
2 changes: 1 addition & 1 deletion PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _save_netpbm(im, fp, filename):

try:
os.unlink(file)
except:
except OSError:
pass


Expand Down
2 changes: 1 addition & 1 deletion PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def close(self):
try:
self.fp.close()
except Exception as msg:
logger.debug("Error closing: %s" % msg)
logger.debug("Error closing: %s", msg)

# Instead of simply setting to None, we're setting up a
# deferred error that will better explain that the core image
Expand Down
6 changes: 2 additions & 4 deletions PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# below for the original description.

from __future__ import print_function
import sys

DESCRIPTION = """
pyCMS
Expand Down Expand Up @@ -240,7 +241,6 @@ def get_display_profile(handle=None):
:returns: None if the profile is not known.
"""

import sys
if sys.platform == "win32":
from PIL import ImageWin
if isinstance(handle, ImageWin.HDC):
Expand Down Expand Up @@ -943,7 +943,6 @@ def versions():
(pyCMS) Fetches versions.
"""

import sys
return (
VERSION, core.littlecms_version,
sys.version.split()[0], Image.VERSION
Expand All @@ -954,10 +953,9 @@ def versions():
if __name__ == "__main__":
# create a cheap manual from the __doc__ strings for the functions above

from PIL import ImageCms
print(__doc__)

for f in dir(ImageCms):
for f in dir(sys.modules[__name__]):
doc = None
try:
exec("doc = %s.__doc__" % (f))
Expand Down
3 changes: 0 additions & 3 deletions PIL/ImageMorph.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def apply(self, image):

if image.mode != 'L':
raise Exception('Image must be binary, meaning it must use mode L')
return
outimage = Image.new(image.mode, image.size, None)
count = _imagingmorph.apply(
bytes(self.lut), image.im.id, outimage.im.id)
Expand All @@ -217,7 +216,6 @@ def match(self, image):

if image.mode != 'L':
raise Exception('Image must be binary, meaning it must use mode L')
return
return _imagingmorph.match(bytes(self.lut), image.im.id)

def get_on_pixels(self, image):
Expand All @@ -228,7 +226,6 @@ def get_on_pixels(self, image):

if image.mode != 'L':
raise Exception('Image must be binary, meaning it must use mode L')
return
return _imagingmorph.get_on_pixels(image.im.id)

def load_lut(self, filename):
Expand Down
2 changes: 1 addition & 1 deletion PIL/IptcImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def load(self):
finally:
try:
os.unlink(outfile)
except:
except OSError:
pass


Expand Down
4 changes: 2 additions & 2 deletions PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def load_djpeg(self):
finally:
try:
os.unlink(path)
except:
except OSError:
pass

self.mode = self.im.mode
Expand Down Expand Up @@ -699,7 +699,7 @@ def _save_cjpeg(im, fp, filename):
subprocess.check_call(["cjpeg", "-outfile", filename, tempfile])
try:
os.unlink(tempfile)
except:
except OSError:
pass


Expand Down
9 changes: 6 additions & 3 deletions Scripts/pildriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def do_composite(self):
self.push(Image.composite(image1, image2, mask))

def do_merge(self):
"""usage: merge <string:mode> <image:pic1> [<image:pic2> [<image:pic3> [<image:pic4>]]]
"""usage: merge <string:mode> <image:pic1>
[<image:pic2> [<image:pic3> [<image:pic4>]]]
Merge top-of stack images in a way described by the mode.
"""
Expand Down Expand Up @@ -181,7 +182,8 @@ def do_copy(self):
self.dup()

def do_crop(self):
"""usage: crop <int:left> <int:upper> <int:right> <int:lower> <image:pic1>
"""usage: crop <int:left> <int:upper> <int:right> <int:lower>
<image:pic1>
Crop and push a rectangular region from the current image.
"""
Expand Down Expand Up @@ -243,7 +245,8 @@ def do_offset(self):
self.push(image.offset(xoff, yoff))

def do_paste(self):
"""usage: paste <image:figure> <int:xoffset> <int:yoffset> <image:ground>
"""usage: paste <image:figure> <int:xoffset> <int:yoffset>
<image:ground>
Paste figure image into ground with upper left at given offsets.
"""
Expand Down
3 changes: 2 additions & 1 deletion Tests/check_jpeg_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


"""
When run on a system without the jpeg leak fixes, the valgrind runs look like this.
When run on a system without the jpeg leak fixes,
the valgrind runs look like this.
NOSE_PROCESSES=0 NOSE_TIMEOUT=600 valgrind --tool=massif \
python test-installed.py -s -v Tests/check_jpeg_leaks.py
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_invalid_file(self):
def test_bad_exif(self):
i = Image.open('Tests/images/hopper_bad_exif.jpg')
try:
self.assert_warning(UserWarning, lambda: i._getexif())
self.assert_warning(UserWarning, i._getexif)
except struct.error:
self.fail(
"Bad EXIF data passed incorrect values to _binary unpack")
Expand Down
8 changes: 3 additions & 5 deletions Tests/test_imagesequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ def test_sanity(self):

self.assertRaises(AttributeError, lambda: ImageSequence.Iterator(0))

def _test_multipage_tiff(self, dbg=False):
def _test_multipage_tiff(self):
im = Image.open('Tests/images/multipage.tiff')
for index, frame in enumerate(ImageSequence.Iterator(im)):
frame.load()
self.assertEqual(index, im.tell())
frame.convert('RGB')

def test_tiff(self):
# self._test_multipage_tiff(True)
self._test_multipage_tiff(False)
self._test_multipage_tiff()

def test_libtiff(self):
codecs = dir(Image.core)
Expand All @@ -42,8 +41,7 @@ def test_libtiff(self):
self.skipTest("tiff support not available")

TiffImagePlugin.READ_LIBTIFF = True
# self._test_multipage_tiff(True)
self._test_multipage_tiff(False)
self._test_multipage_tiff()
TiffImagePlugin.READ_LIBTIFF = False

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_imagewin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_removed_methods(self):

# Act/Assert
self.assertRaises(Exception, dib.tostring)
self.assertRaises(Exception, lambda: dib.fromstring(test_buffer))
self.assertRaises(Exception, dib.fromstring)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_imagewin_pointers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_pointer(self):
DeleteObject(dib)
DeleteDC(hdc)

reloaded = Image.open(BytesIO(bitmap)).save(opath)
Image.open(BytesIO(bitmap)).save(opath)

if __name__ == '__main__':
unittest.main()
Expand Down
3 changes: 1 addition & 2 deletions selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ def testimage():

# use doctest to make sure the test program behaves as documented!
import doctest
import selftest
print("Running selftest:")
status = doctest.testmod(selftest)
status = doctest.testmod(sys.modules[__name__])
if status[0]:
print("*** %s tests of %d failed." % status)
exit_status = 1
Expand Down

0 comments on commit c32a825

Please sign in to comment.