fix deprecation warnings when using ABC from collections module

This commit is contained in:
Cosimo Lupo 2018-10-18 18:12:43 +01:00
parent 4be92cc6da
commit 9557c6a229
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
3 changed files with 16 additions and 7 deletions

View File

@ -8,7 +8,10 @@ import sys
import logging
import timeit
from functools import wraps
import collections
try:
from collections.abc import Mapping, Callable
except ImportError: # python < 3.3
from collections import Mapping, Callable
import warnings
try:
@ -64,7 +67,7 @@ class LevelFormatter(logging.Formatter):
if isinstance(fmt, basestring):
default_format = fmt
custom_formats = {}
elif isinstance(fmt, collections.Mapping):
elif isinstance(fmt, Mapping):
custom_formats = dict(fmt)
default_format = custom_formats.pop("*", None)
else:
@ -360,7 +363,7 @@ class Timer(object):
Timer instance, referencing the same logger.
A 'level' keyword can also be passed to override self.level.
"""
if isinstance(func_or_msg, collections.Callable):
if isinstance(func_or_msg, Callable):
func = func_or_msg
# use the function name when no explicit 'msg' is provided
if not self.msg:

View File

@ -3,7 +3,10 @@ from fontTools.misc.py23 import *
from fontTools.misc import eexec
from .psOperators import *
import re
import collections
try:
from collections.abc import Callable
except ImportError: # python < 3.3
from collections import Callable
from string import whitespace
import logging
@ -169,7 +172,7 @@ class PSInterpreter(PSOperators):
def suckoperators(self, systemdict, klass):
for name in dir(klass):
attr = getattr(self, name)
if isinstance(attr, collections.Callable) and name[:3] == 'ps_':
if isinstance(attr, Callable) and name[:3] == 'ps_':
name = name[3:]
systemdict[name] = ps_operator(name, attr)
for baseclass in klass.__bases__:

View File

@ -2,7 +2,10 @@
from __future__ import (print_function, division, absolute_import,
unicode_literals)
import collections
try:
from collections.abc import Iterable
except ImportError: # python < 3.3
from collections import Iterable
import os
import shutil
import sys
@ -29,7 +32,7 @@ def parseXML(xmlSnippet):
xml += xmlSnippet
elif isinstance(xmlSnippet, unicode):
xml += tobytes(xmlSnippet, 'utf-8')
elif isinstance(xmlSnippet, collections.Iterable):
elif isinstance(xmlSnippet, Iterable):
xml += b"".join(tobytes(s, 'utf-8') for s in xmlSnippet)
else:
raise TypeError("expected string or sequence of strings; found %r"