From 16fb3d5845a0d317ef53cfe781869360923894b2 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Wed, 22 Jan 2020 22:52:20 +0530 Subject: [PATCH] Import ABC from collections.abc instead of collections for Python 3.9 compatibility. --- distroinfo/parse.py | 9 +++++++-- distroinfo/query.py | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/distroinfo/parse.py b/distroinfo/parse.py index 200c56f..426800e 100644 --- a/distroinfo/parse.py +++ b/distroinfo/parse.py @@ -16,6 +16,11 @@ import copy import six +try: + from collections.abc import Iterable +except ImportError: + from collections import Iterable + from distroinfo import exception @@ -48,7 +53,7 @@ def parse_releases(info): releases = info['releases'] except KeyError: raise exception.MissingRequiredSection(section='releases') - if not isinstance(releases, collections.Iterable): + if not isinstance(releases, Iterable): raise exception.InvalidInfoFormat( msg="'releases' section must be iterable") if isinstance(releases, dict): @@ -148,7 +153,7 @@ def parse_packages(info, apply_tag=None): pkgs = info['packages'] except KeyError: raise exception.MissingRequiredSection(section='packages') - if not isinstance(pkgs, collections.Iterable): + if not isinstance(pkgs, Iterable): raise exception.InvalidInfoFormat( msg="'packages' section must be iterable") if isinstance(pkgs, dict): diff --git a/distroinfo/query.py b/distroinfo/query.py index a5f8058..670f8e3 100644 --- a/distroinfo/query.py +++ b/distroinfo/query.py @@ -13,11 +13,15 @@ # under the License. from __future__ import print_function -import collections from functools import partial import re import six +try: + from collections.abc import Iterable +except ImportError: + from collections import Iterable + from distroinfo import exception @@ -77,7 +81,7 @@ def _match_pkg(rexen, pkg): if isinstance(val, six.string_types): if not re.search(rex, val): return False - elif isinstance(val, collections.Iterable): + elif isinstance(val, Iterable): # collection matches if any item of collection matches found = False for e in val: