Skip to content

Commit a0dea53

Browse files
committed
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.
1 parent f9b5d7f commit a0dea53

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/bap/adt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def count_authors(library):
182182
183183
"""
184184

185-
from collections import Iterable,Sequence,Mapping
185+
try:
186+
from collections.abc import Iterable,Sequence,Mapping
187+
except ImportError:
188+
from collections import Iterable,Sequence,Mapping
186189

187190
class ADT(object):
188191
"""Algebraic Data Type.

src/bap/bir.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
"""BIR - BAP Intermediate Representation"""
44

5-
from collections import Sequence,Mapping
5+
try:
6+
from collections.abc import Sequence,Mapping
7+
except ImportError:
8+
from collections import Sequence,Mapping
69
from .adt import *
710
from .bil import *
811
from . import noeval_parser

0 commit comments

Comments
 (0)