From a0dea5309d2f369245f7ba990a7fd63782996a3a Mon Sep 17 00:00:00 2001 From: George Macon Date: Fri, 20 Jan 2023 16:09:43 -0500 Subject: [PATCH] Import collection ABCs from new path Importing the Iterable, Sequence, and Mapping ABCs directly from collections was deprecated in Python 3.3 and the aliases were removed in Python 3.10. Attempt to import from the new location, but if it fails because the current Python is older than 3.3, fall back to the old location. --- src/bap/adt.py | 5 ++++- src/bap/bir.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bap/adt.py b/src/bap/adt.py index bb9311f..02129d9 100755 --- a/src/bap/adt.py +++ b/src/bap/adt.py @@ -182,7 +182,10 @@ def count_authors(library): """ -from collections import Iterable,Sequence,Mapping +try: + from collections.abc import Iterable,Sequence,Mapping +except ImportError: + from collections import Iterable,Sequence,Mapping class ADT(object): """Algebraic Data Type. diff --git a/src/bap/bir.py b/src/bap/bir.py index d310c3c..9606005 100644 --- a/src/bap/bir.py +++ b/src/bap/bir.py @@ -2,7 +2,10 @@ """BIR - BAP Intermediate Representation""" -from collections import Sequence,Mapping +try: + from collections.abc import Sequence,Mapping +except ImportError: + from collections import Sequence,Mapping from .adt import * from .bil import * from . import noeval_parser