diff --git a/PIL/Image.py b/PIL/Image.py index 3865e9c0f..e83899cce 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -28,7 +28,13 @@ from __future__ import print_function from PIL import VERSION, PILLOW_VERSION, _plugins +import sys import logging +if sys.version_info < (2, 7): + class NullHandler(logging.Handler): + def emit(self, record): + pass + logging.NullHandler = NullHandler import warnings logger = logging.getLogger(__name__) @@ -112,7 +118,6 @@ from PIL._util import isStringType from PIL._util import deferred_error import os -import sys import io import struct diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index 88952649d..38d709b64 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -36,6 +36,8 @@ import sys import struct logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler()) MAXBLOCK = 65536 diff --git a/PIL/PcxImagePlugin.py b/PIL/PcxImagePlugin.py index ef057ed11..f443c5ec4 100644 --- a/PIL/PcxImagePlugin.py +++ b/PIL/PcxImagePlugin.py @@ -27,10 +27,13 @@ from __future__ import print_function +import sys import logging from PIL import Image, ImageFile, ImagePalette, _binary logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler()) i8 = _binary.i8 diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index ec7c4c59b..92156c0e4 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -33,6 +33,7 @@ from __future__ import print_function +import sys import logging import re import zlib @@ -42,6 +43,8 @@ from PIL import Image, ImageFile, ImagePalette, _binary __version__ = "0.9" logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler()) i8 = _binary.i8 diff --git a/PIL/PyAccess.py b/PIL/PyAccess.py index 8c1e4558d..5e4c77750 100644 --- a/PIL/PyAccess.py +++ b/PIL/PyAccess.py @@ -29,6 +29,9 @@ from cffi import FFI logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + from PIL import Image + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler()) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 2abf605b4..59190a4c0 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -3,6 +3,7 @@ from helper import unittest, PillowTestCase, hopper, py3 from ctypes import c_float import io +import sys import logging import itertools import os @@ -10,6 +11,8 @@ import os from PIL import Image, TiffImagePlugin logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler()) diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 9141668c3..a39600e9e 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -1,4 +1,5 @@ from __future__ import print_function +import sys import logging import struct @@ -7,6 +8,8 @@ from helper import unittest, PillowTestCase, hopper, py3 from PIL import Image, TiffImagePlugin logger = logging.getLogger(__name__) +if sys.version_info < (2, 7): + logging.NullHandler = Image.NullHandler logger.addHandler(logging.NullHandler())