Merge pull request #3123 from hugovk/collections.abc-deprecationwarning

Fix collections ABCs DeprecationWarning in Python 3.7
This commit is contained in:
Alex Clark 2018-06-30 18:00:10 -04:00 committed by GitHub
commit 9e5494e9a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -121,8 +121,14 @@ import struct
import atexit import atexit
# type stuff # type stuff
import collections
import numbers import numbers
try:
# Python 3
from collections.abc import Callable
except ImportError:
# Python 2.7
from collections import Callable
# works everywhere, win for pypy, not cpython # works everywhere, win for pypy, not cpython
USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info') USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info')
@ -1145,7 +1151,7 @@ class Image(object):
self.load() self.load()
if isinstance(filter, collections.Callable): if isinstance(filter, Callable):
filter = filter() filter = filter()
if not hasattr(filter, "filter"): if not hasattr(filter, "filter"):
raise TypeError("filter argument should be ImageFilter.Filter " + raise TypeError("filter argument should be ImageFilter.Filter " +

View File

@ -58,6 +58,13 @@ import warnings
from .TiffTags import TYPES from .TiffTags import TYPES
try:
# Python 3
from collections.abc import MutableMapping
except ImportError:
# Python 2.7
from collections import MutableMapping
__version__ = "1.3.5" __version__ = "1.3.5"
DEBUG = False # Needs to be merged with the new logging approach. DEBUG = False # Needs to be merged with the new logging approach.
@ -398,7 +405,7 @@ class IFDRational(Rational):
__round__ = _delegate('__round__') __round__ = _delegate('__round__')
class ImageFileDirectory_v2(collections.MutableMapping): class ImageFileDirectory_v2(MutableMapping):
"""This class represents a TIFF tag directory. To speed things up, we """This class represents a TIFF tag directory. To speed things up, we
don't decode tags unless they're asked for. don't decode tags unless they're asked for.