From 11c23a526ae926ca082ee7ad92246e085c51b8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blaisot?= Date: Fri, 17 Jan 2020 17:06:42 +0100 Subject: [PATCH] Import abstract base classes from collection.abc in python 3.3+ --- salt/modules/file.py | 6 +++++- salt/modules/win_file.py | 5 ++++- salt/states/file.py | 6 +++++- salt/utils/dictdiffer.py | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 771b204d63fe..d1ec5e4c295d 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -29,7 +29,11 @@ import glob import hashlib import mmap -from collections import Iterable, Mapping, namedtuple +try: + from collections.abc import Iterable, Mapping +except ImportError: + from collections import Iterable, Mapping +from collections import namedtuple from functools import reduce # pylint: disable=redefined-builtin # pylint: disable=import-error,no-name-in-module,redefined-builtin diff --git a/salt/modules/win_file.py b/salt/modules/win_file.py index 4fd3eebcdd81..5bc983786a98 100644 --- a/salt/modules/win_file.py +++ b/salt/modules/win_file.py @@ -17,7 +17,10 @@ import logging # pylint: disable=W0611 import operator # do not remove -from collections import Iterable, Mapping # do not remove +try: + from collections.abc import Iterable, Mapping # do not remove +except ImportError: + from collections import Iterable, Mapping # do not remove from functools import reduce # do not remove import datetime # do not remove. import tempfile # do not remove. Used in salt.modules.file.__clean_tmp diff --git a/salt/states/file.py b/salt/states/file.py index 23c3d3c53955..36231c69cff6 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -291,7 +291,11 @@ def run(): import sys import time import traceback -from collections import Iterable, Mapping, defaultdict +try: + from collections.abc import Iterable, Mapping +except ImportError: + from collections import Iterable, Mapping +from collections import defaultdict from datetime import datetime, date # python3 problem in the making? # Import salt libs diff --git a/salt/utils/dictdiffer.py b/salt/utils/dictdiffer.py index 30e87e885436..da6bd5ed944c 100644 --- a/salt/utils/dictdiffer.py +++ b/salt/utils/dictdiffer.py @@ -13,7 +13,10 @@ ''' from __future__ import absolute_import, print_function, unicode_literals import copy -from collections import Mapping +try: + from collections.abc import Mapping +except ImportError: + from collections import Mapping from salt.ext import six