Swapping out the version check for a try...except on the import from collections.abc with a fallback to importing from collections.

This commit is contained in:
Gareth J. Greenaway 2018-09-03 16:30:21 -07:00
parent d118a9fe53
commit b27e86bd7d
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
10 changed files with 25 additions and 30 deletions

View file

@ -7,11 +7,12 @@ from __future__ import absolute_import, print_function, unicode_literals
# Import Python Libs
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import Iterable, Sequence, Mapping
from collections import namedtuple
else:
from collections import namedtuple, Iterable, Sequence, Mapping
except ImportError:
from collections import Iterable, Sequence, Mapping
from collections import namedtuple
import logging

View file

@ -24,9 +24,9 @@ import salt.utils.versions
from salt.utils.args import get_function_argspec as _argspec
from salt.utils.decorators import ensure_unicode_args
if sys.version_info > (3, 7):
try:
from collections.abc import Sequence
else:
except ImportError:
from collections import Sequence
# Import 3rd-party libs

View file

@ -49,9 +49,9 @@ else:
import imp
USE_IMPORTLIB = False
if sys.version_info > (3, 7):
try:
from collections.abc import MutableMapping
else:
except ImportError:
from collections import MutableMapping
try:

View file

@ -14,10 +14,9 @@ from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import copy
import threading
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import MutableMapping
else:
except ImportError:
from collections import MutableMapping
from contextlib import contextmanager

View file

@ -11,12 +11,11 @@ import copy
import fnmatch
import logging
import re
import sys
if sys.version_info > (3, 7):
from collections.abc import MutableMapping, Mapping
else:
from collections import MutableMapping, Mapping
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
# Import Salt libs
import salt.utils.dictupdate

View file

@ -6,11 +6,10 @@ http://stackoverflow.com/a/3233356
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import Mapping
else:
except ImportError:
from collections import Mapping
# Import 3rd-party libs

View file

@ -61,9 +61,9 @@ import logging
import datetime
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import MutableMapping
else:
except ImportError:
from collections import MutableMapping
from multiprocessing.util import Finalize

View file

@ -11,10 +11,9 @@
from __future__ import absolute_import, unicode_literals
# Import python libs
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import Mapping, Sequence, Set
else:
except ImportError:
from collections import Mapping, Sequence, Set

View file

@ -6,12 +6,11 @@ Lazily-evaluated data structures, primarily used by Salt's loader
# Import Python Libs
from __future__ import absolute_import, unicode_literals
import logging
import sys
import salt.exceptions
if sys.version_info > (3, 7):
try:
from collections.abc import MutableMapping
else:
except ImportError:
from collections import MutableMapping
log = logging.getLogger(__name__)

View file

@ -23,10 +23,9 @@
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import sys
if sys.version_info > (3, 7):
try:
from collections.abc import Callable
else:
except ImportError:
from collections import Callable
# Import 3rd-party libs