Import ABC from collections.abc instead of collections for Python 3.9 compatibility.

This commit is contained in:
Karthikeyan Singaravelan 2020-02-09 17:24:27 +05:30
parent 4cb7d26f55
commit 212146fece
2 changed files with 11 additions and 4 deletions

View File

@ -3,7 +3,6 @@ from .dag import get_outgoing_edges, topo_sort
from ._utils import basestring, convert_kwargs_to_cmd_line_args
from builtins import str
from functools import reduce
import collections
import copy
import operator
import subprocess
@ -18,6 +17,10 @@ from .nodes import (
output_operator,
)
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
class Error(Exception):
def __init__(self, cmd, stdout, stderr):
@ -137,7 +140,7 @@ def _get_output_args(node, stream_name_map):
if 'video_size' in kwargs:
video_size = kwargs.pop('video_size')
if not isinstance(video_size, basestring) and isinstance(
video_size, collections.Iterable
video_size, Iterable
):
video_size = '{}x{}'.format(video_size[0], video_size[1])
args += ['-video_size', video_size]

View File

@ -3,13 +3,17 @@ from builtins import str
from past.builtins import basestring
import hashlib
import sys
import collections
if sys.version_info.major == 2:
# noinspection PyUnresolvedReferences,PyShadowingBuiltins
str = str
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
# `past.builtins.basestring` module can't be imported on Python3 in some environments (Ubuntu).
# This code is copy-pasted from it to avoid crashes.
@ -93,7 +97,7 @@ def convert_kwargs_to_cmd_line_args(kwargs):
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
if isinstance(v, collections.Iterable) and not isinstance(v, str):
if isinstance(v, Iterable) and not isinstance(v, str):
for value in v:
args.append('-{}'.format(k))
if value is not None: