summaryrefslogtreecommitdiff
blob: e9f64b664178b48d279f6796964ce1fb04e5990e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 11c23a526ae926ca082ee7ad92246e085c51b8e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blaisot?= <sebastien@blaisot.org>
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