diff --git a/PIL/BdfFontFile.py b/PIL/BdfFontFile.py index 98bfd3443..c525c1343 100644 --- a/PIL/BdfFontFile.py +++ b/PIL/BdfFontFile.py @@ -17,7 +17,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function from PIL import Image, FontFile from .exceptions import InvalidFileType @@ -108,20 +107,6 @@ class BdfFontFile(FontFile.FontFile): if s.find(b"LogicalFontDescription") < 0: comments.append(s[i+1:-1].decode('ascii')) - # font = props["FONT"].split("-") - - # font[4] = bdf_slant[font[4].upper()] - # font[11] = bdf_spacing[font[11].upper()] - - # ascent = int(props["FONT_ASCENT"]) - # descent = int(props["FONT_DESCENT"]) - - # fontname = ";".join(font[1:]) - - # print("#", fontname) - # for i in comments: - # print("#", i) - while True: c = bdf_char(fp) if not c: diff --git a/PIL/CurImagePlugin.py b/PIL/CurImagePlugin.py index 16faf4583..ece3f5db7 100644 --- a/PIL/CurImagePlugin.py +++ b/PIL/CurImagePlugin.py @@ -16,7 +16,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function from PIL import Image, BmpImagePlugin, _binary from .exceptions import InvalidFileType @@ -60,14 +59,6 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): m = s elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]): m = s - # print("width", i8(s[0])) - # print("height", i8(s[1])) - # print("colors", i8(s[2])) - # print("reserved", i8(s[3])) - # print("hotspot x", i16(s[4:])) - # print("hotspot y", i16(s[6:])) - # print("bytes", i32(s[8:])) - # print("offset", i32(s[12:])) if not m: raise TypeError("No cursors were found") diff --git a/PIL/FontFile.py b/PIL/FontFile.py index 807984a8c..d55b7a86c 100644 --- a/PIL/FontFile.py +++ b/PIL/FontFile.py @@ -14,8 +14,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - import os from PIL import Image, _binary @@ -90,7 +88,6 @@ class FontFile(object): x = xx s = src[0] + x0, src[1] + y0, src[2] + x0, src[3] + y0 self.bitmap.paste(im.crop(src), s) - # print(chr(i), dst, s) self.metrics[i] = d, dst, s def save(self, filename): diff --git a/PIL/FpxImagePlugin.py b/PIL/FpxImagePlugin.py index 4bcac10a8..c98cebdfb 100644 --- a/PIL/FpxImagePlugin.py +++ b/PIL/FpxImagePlugin.py @@ -15,7 +15,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function import olefile from PIL import Image, ImageFile, _binary from .exceptions import InvalidFileType, PILReadError @@ -116,8 +115,6 @@ class FpxImageFile(ImageFile.ImageFile): if id in prop: self.jpeg[i] = prop[id] - # print(len(self.jpeg), "tables loaded") - self._open_subimage(1, self.maxid) def _open_subimage(self, index=1, subimage=0): @@ -145,8 +142,6 @@ class FpxImageFile(ImageFile.ImageFile): offset = i32(s, 28) length = i32(s, 32) - # print(size, self.mode, self.rawmode) - if size != self.size: raise PILReadError("subimage mismatch") diff --git a/PIL/Image.py b/PIL/Image.py index d88a54800..676491a55 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -24,12 +24,9 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - import logging import math import warnings - from PIL import VERSION, PILLOW_VERSION, _plugins from .exceptions import PILReadError, NoPluginFound @@ -419,7 +416,6 @@ def _getdecoder(mode, decoder_name, args, extra=()): try: # get decoder decoder = getattr(core, decoder_name + "_decoder") - # print(decoder, mode, args + extra) return decoder(mode, *args + extra) except AttributeError: raise IOError("decoder %s not available" % decoder_name) @@ -436,7 +432,6 @@ def _getencoder(mode, encoder_name, args, extra=()): try: # get encoder encoder = getattr(core, encoder_name + "_encoder") - # print(encoder, mode, args + extra) return encoder(mode, *args + extra) except AttributeError: raise IOError("encoder %s not available" % encoder_name) @@ -2195,7 +2190,6 @@ def fromarray(obj, mode=None): typekey = (1, 1) + shape[2:], arr['typestr'] mode, rawmode = _fromarray_typemap[typekey] except KeyError: - # print(typekey) raise TypeError("Cannot handle this data type") else: rawmode = mode diff --git a/PIL/ImageCms.py b/PIL/ImageCms.py index 267afa4c6..327b27cb7 100644 --- a/PIL/ImageCms.py +++ b/PIL/ImageCms.py @@ -15,7 +15,6 @@ # See the README file for information on usage and redistribution. See # below for the original description. -from __future__ import print_function import sys from PIL import Image @@ -28,6 +27,7 @@ except ImportError as ex: _imagingcms = deferred_error(ex) from PIL._util import isStringType + DESCRIPTION = """ pyCMS @@ -149,7 +149,6 @@ for flag in FLAGS.values(): # Profile. class ImageCmsProfile(object): - def __init__(self, profile): """ :param profile: Either a string representing a filename, @@ -166,7 +165,6 @@ class ImageCmsProfile(object): self._set(profile) else: raise TypeError("Invalid type for Profile") - def _set(self, profile, filename=None): self.profile = profile diff --git a/PIL/ImageMorph.py b/PIL/ImageMorph.py index 3ad708291..6814858e8 100644 --- a/PIL/ImageMorph.py +++ b/PIL/ImageMorph.py @@ -5,11 +5,10 @@ # # Copyright (c) 2014 Dov Grobgeld -from __future__ import print_function - +import re from PIL import Image from PIL import _imagingmorph -import re + LUT_SIZE = 1 << 9 @@ -152,11 +151,6 @@ class LutBuilder(object): patterns += self._pattern_permute(pattern, options, result) -# # Debugging -# for p,r in patterns: -# print(p,r) -# print('--') - # compile the patterns into regular expressions for speed for i, pattern in enumerate(patterns): p = pattern[0].replace('.', 'X').replace('X', '[01]') diff --git a/PIL/ImageShow.py b/PIL/ImageShow.py index 33f059d74..d439190d6 100644 --- a/PIL/ImageShow.py +++ b/PIL/ImageShow.py @@ -12,8 +12,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - from PIL import Image import os import sys diff --git a/PIL/IptcImagePlugin.py b/PIL/IptcImagePlugin.py index b07e27ba9..a1240b8d2 100644 --- a/PIL/IptcImagePlugin.py +++ b/PIL/IptcImagePlugin.py @@ -15,7 +15,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function import os import tempfile from PIL import Image, ImageFile, _binary @@ -44,12 +43,6 @@ def i(c): return i32((PAD + c)[-4:]) -def dump(c): - for i in c: - print("%02x" % i8(i), end=' ') - print() - - ## # Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields # from TIFF and JPEG files, use the getiptcinfo function. @@ -108,8 +101,6 @@ class IptcImageFile(ImageFile.ImageFile): else: self.info[tag] = tagdata - # print(tag, self.info[tag]) - # mode layers = i8(self.info[(3, 60)][0]) component = i8(self.info[(3, 60)][1]) diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 9dbc42a60..50e049719 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -32,8 +32,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - import array import struct import io @@ -319,7 +317,6 @@ class JpegImageFile(ImageFile.ImageFile): if i in MARKER: name, description, handler = MARKER[i] - # print(hex(i), name, description) if handler is not None: handler(self, i) if i == 0xFFDA: # start of scan diff --git a/PIL/PcxImagePlugin.py b/PIL/PcxImagePlugin.py index a5e7dd4c4..f103a4d39 100644 --- a/PIL/PcxImagePlugin.py +++ b/PIL/PcxImagePlugin.py @@ -25,8 +25,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - import logging from PIL import Image, ImageFile, ImagePalette, _binary from .exceptions import InvalidFileType, PILReadError @@ -54,7 +52,6 @@ class PcxImageFile(ImageFile.ImageFile): format_description = "Paintbrush" def _open(self): - # header s = self.fp.read(128) if not _accept(s): diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index b44bc9e36..e2dda77c3 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -31,8 +31,6 @@ # See the README file for information on usage and redistribution. # -from __future__ import print_function - import logging import re import zlib diff --git a/PIL/PyAccess.py b/PIL/PyAccess.py index 8b67a8ea2..dd7e9e264 100644 --- a/PIL/PyAccess.py +++ b/PIL/PyAccess.py @@ -20,11 +20,8 @@ # Access.c implementation. # -from __future__ import print_function - import logging import sys - from cffi import FFI diff --git a/PIL/WalImageFile.py b/PIL/WalImageFile.py index 1167fa739..c77fa26bc 100644 --- a/PIL/WalImageFile.py +++ b/PIL/WalImageFile.py @@ -21,8 +21,6 @@ # http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml # and has been tested with a few sample files found using google. -from __future__ import print_function - from PIL import Image, _binary try: diff --git a/PIL/WmfImagePlugin.py b/PIL/WmfImagePlugin.py index e2bc71bad..b904fa9c8 100644 --- a/PIL/WmfImagePlugin.py +++ b/PIL/WmfImagePlugin.py @@ -19,8 +19,6 @@ # http://wvware.sourceforge.net/caolan/index.html # http://wvware.sourceforge.net/caolan/ora-wmf.html -from __future__ import print_function - from PIL import Image, ImageFile, _binary from .exceptions import InvalidFileType @@ -112,8 +110,6 @@ class WmfStubImageFile(ImageFile.StubImageFile): self.info["dpi"] = 72 - # print(self.mode, self.size, self.info) - # sanity check (standard metafile header) if s[22:26] != b"\x01\x00\t\x00": raise NotImplementedError("Unsupported WMF file format") diff --git a/Tests/helper.py b/Tests/helper.py index c5ec253ca..632b5c021 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -1,12 +1,10 @@ """ Helper functions. """ -from __future__ import print_function +import os import sys import tempfile -import os import unittest - from PIL import Image, ImageMath diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index fa4571e60..56c113d3c 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -1,8 +1,7 @@ -from __future__ import print_function +import os +from PIL import Image from helper import unittest, PillowTestCase -from PIL import Image -import os base = os.path.join('Tests', 'images', 'bmp') @@ -22,7 +21,6 @@ class TestBmpReference(PillowTestCase): im.load() except Exception: # as msg: pass - # print("Bad Image %s: %s" %(f,msg)) def test_questionable(self): """ These shouldn't crash/dos, but it's not well defined that these @@ -47,7 +45,6 @@ class TestBmpReference(PillowTestCase): except Exception: # as msg: if os.path.basename(f) in supported: raise - # print("Bad Image %s: %s" %(f,msg)) def test_good(self): """ These should all work. There's a set of target files in the diff --git a/Tests/test_file_iptc.py b/Tests/test_file_iptc.py index a29e1a4a6..085b007c0 100644 --- a/Tests/test_file_iptc.py +++ b/Tests/test_file_iptc.py @@ -39,27 +39,6 @@ class TestFileIptc(PillowTestCase): # Assert self.assertEqual(ret, 97) - def test_dump(self): - # Arrange - c = b"abc" - # Temporarily redirect stdout - try: - from cStringIO import StringIO - except ImportError: - from io import StringIO - import sys - old_stdout = sys.stdout - sys.stdout = mystdout = StringIO() - - # Act - IptcImagePlugin.dump(c) - - # Reset stdout - sys.stdout = old_stdout - - # Assert - self.assertEqual(mystdout.getvalue(), "61 62 63 \n") - if __name__ == '__main__': unittest.main() diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index 96f82054e..8c127570d 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -48,29 +48,6 @@ class TestImageSpider(PillowTestCase): self.assertEqual(im.n_frames, 1) self.assertFalse(im.is_animated) - def test_loadImageSeries(self): - # Arrange - not_spider_file = "Tests/images/hopper.ppm" - file_list = [TEST_FILE, not_spider_file, "path/not_found.ext"] - - # Act - img_list = SpiderImagePlugin.loadImageSeries(file_list) - - # Assert - self.assertEqual(len(img_list), 1) - self.assertIsInstance(img_list[0], Image.Image) - self.assertEqual(img_list[0].size, (128, 128)) - - def test_loadImageSeries_no_input(self): - # Arrange - file_list = None - - # Act - img_list = SpiderImagePlugin.loadImageSeries(file_list) - - # Assert - self.assertEqual(img_list, None) - def test_isInt_not_a_number(self): # Arrange not_a_number = "a" diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index eea29b3f1..89c065dab 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -1,10 +1,7 @@ -from __future__ import print_function -from helper import unittest, PillowTestCase, hopper - -from PIL import Image - import colorsys import itertools +from PIL import Image +from helper import unittest, PillowTestCase, hopper class TestFormatHSV(PillowTestCase): @@ -47,10 +44,6 @@ class TestFormatHSV(PillowTestCase): img = Image.merge('RGB', (r, g, b)) - # print(("%d, %d -> "% (int(1.75*px),int(.25*px))) + \ - # "(%s, %s, %s)"%img.getpixel((1.75*px, .25*px))) - # print(("%d, %d -> "% (int(.75*px),int(.25*px))) + \ - # "(%s, %s, %s)"%img.getpixel((.75*px, .25*px))) return img def to_xxx_colorsys(self, im, func, mode): @@ -95,15 +88,6 @@ class TestFormatHSV(PillowTestCase): im = src.convert('HSV') comparable = self.to_hsv_colorsys(src) - # print(im.getpixel((448, 64))) - # print(comparable.getpixel((448, 64))) - - # print(im.split()[0].histogram()) - # print(comparable.split()[0].histogram()) - - # im.split()[0].show() - # comparable.split()[0].show() - self.assert_image_similar(im.split()[0], comparable.split()[0], 1, "Hue conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], @@ -111,16 +95,9 @@ class TestFormatHSV(PillowTestCase): self.assert_image_similar(im.split()[2], comparable.split()[2], 1, "Value conversion is wrong") - # print(im.getpixel((192, 64))) - comparable = src im = im.convert('RGB') - # im.split()[0].show() - # comparable.split()[0].show() - # print(im.getpixel((192, 64))) - # print(comparable.getpixel((192, 64))) - self.assert_image_similar(im.split()[0], comparable.split()[0], 3, "R conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], @@ -132,12 +109,6 @@ class TestFormatHSV(PillowTestCase): im = hopper('RGB').convert('HSV') comparable = self.to_hsv_colorsys(hopper('RGB')) -# print([ord(x) for x in im.split()[0].tobytes()[:80]]) -# print([ord(x) for x in comparable.split()[0].tobytes()[:80]]) - -# print(im.split()[0].histogram()) -# print(comparable.split()[0].histogram()) - self.assert_image_similar(im.split()[0], comparable.split()[0], 1, "Hue conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], @@ -150,12 +121,6 @@ class TestFormatHSV(PillowTestCase): converted = comparable.convert('RGB') comparable = self.to_rgb_colorsys(comparable) - # print(converted.split()[1].histogram()) - # print(target.split()[1].histogram()) - - # print([ord(x) for x in target.split()[1].tobytes()[:80]]) - # print([ord(x) for x in converted.split()[1].tobytes()[:80]]) - self.assert_image_similar(converted.split()[0], comparable.split()[0], 3, "R conversion is wrong") self.assert_image_similar(converted.split()[1], comparable.split()[1], diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 7ae687e2f..0a32e97de 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -1,6 +1,5 @@ -from __future__ import print_function -from helper import unittest, PillowTestCase, hopper from PIL import Image, ImageDraw, ImageMode +from helper import unittest, PillowTestCase, hopper class TestImagingResampleVulnerability(PillowTestCase): @@ -324,10 +323,8 @@ class CoreResamplePassesTest(PillowTestCase): class CoreResampleCoefficientsTest(PillowTestCase): def test_reduce(self): test_color = 254 - # print() for size in range(400000, 400010, 2): - # print(size) i = Image.new('L', (size, 1), 0) draw = ImageDraw.Draw(i) draw.rectangle((0, 0, i.size[0] // 2 - 1, 0), test_color) @@ -335,7 +332,6 @@ class CoreResampleCoefficientsTest(PillowTestCase): px = i.resize((5, i.size[1]), Image.BICUBIC).load() if px[2, 0] != test_color // 2: self.assertEqual(test_color // 2, px[2, 0]) - # print('>', size, test_color // 2, px[2, 0]) def test_nonzero_coefficients(self): # regression test for the wrong coefficients calculation diff --git a/Tests/test_imagemath.py b/Tests/test_imagemath.py index 4f99eda93..a54d219d7 100644 --- a/Tests/test_imagemath.py +++ b/Tests/test_imagemath.py @@ -1,9 +1,6 @@ -from __future__ import print_function +from PIL import Image, ImageMath from helper import unittest, PillowTestCase -from PIL import Image -from PIL import ImageMath - def pixel(im): if hasattr(im, "im"): diff --git a/Tests/test_locale.py b/Tests/test_locale.py index 142753791..41f777592 100644 --- a/Tests/test_locale.py +++ b/Tests/test_locale.py @@ -1,9 +1,7 @@ -from __future__ import print_function +import locale +from PIL import Image from helper import unittest, PillowTestCase -from PIL import Image - -import locale # ref https://github.com/python-pillow/Pillow/issues/272 # on windows, in polish locale: diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 02ae5e50b..aeb78b04f 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -54,7 +54,6 @@ class TestNumpy(PillowTestCase): i = Image.fromarray(a) if list(i.split()[0].getdata()) != list(range(100)): print("data mismatch for", dtype) - # print(dtype, list(i.getdata())) return i # Check supported 1-bit integer formats diff --git a/Tests/test_tiff_ifdrational.py b/Tests/test_tiff_ifdrational.py index ffd4f9eac..ae4076aff 100644 --- a/Tests/test_tiff_ifdrational.py +++ b/Tests/test_tiff_ifdrational.py @@ -1,11 +1,7 @@ -from __future__ import print_function - -from helper import unittest, PillowTestCase, hopper - +from fractions import Fraction from PIL import TiffImagePlugin, Image from PIL.TiffImagePlugin import IFDRational - -from fractions import Fraction +from helper import unittest, PillowTestCase, hopper class Test_IFDRational(PillowTestCase):