Skip to content

Commit

Permalink
for 3.10 compatibility, attempt import of abstract collections from c…
Browse files Browse the repository at this point in the history
…ollections.abc and then from collections (for pre 3.10)
  • Loading branch information
jeff-wishnie authored and tgregg committed Oct 25, 2021
1 parent 0c6a622 commit 90f5b5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion amazon/ion/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
from __future__ import division
from __future__ import print_function

from collections import MutableMapping, MutableSequence, OrderedDict
# in Python 3.10, abstract collections have moved into their own module
# for compatibility with 3.10+, first try imports from the new location
# if that fails, try from the pre-3.10 location
try:
from collections.abc import MutableMapping, MutableSequence
from collections import OrderedDict
except:
from collections import MutableMapping, MutableSequence, OrderedDict

from datetime import datetime, timedelta, tzinfo
from decimal import Decimal, ROUND_FLOOR, Context, Inexact
from math import isnan
Expand Down
9 changes: 8 additions & 1 deletion amazon/ion/simple_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
from __future__ import print_function

from decimal import Decimal
from collections import MutableMapping

# in Python 3.10, abstract collections have moved into their own module
# for compatibility with 3.10+, first try imports from the new location
# if that fails, try from the pre-3.10 location
try:
from collections.abc import MutableMapping
except:
from collections import MutableMapping

import six

Expand Down

0 comments on commit 90f5b5d

Please sign in to comment.