Python 3.7 support - deprecation of classes in the collections module

Change the base classes in the pyabc.i file to use the
collections.abc module instead of collections due to the deprecation
of the classes in the collections module in Python 3.7.
diff --git a/CHANGES.current b/CHANGES.current
index f60516c..873f2b4 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,22 @@
 Version 4.0.0 (in progress)
 ===========================
 
+2018-06-12: wsfulton
+            [Python] The %pythonabc feature in pyabc.i now uses base classes
+              collections.abc.MutableSequence
+              collections.abc.MutableMapping
+              collections.abc.MutableSet
+            instead of
+              collections.MutableSequence
+              collections.MutableMapping
+              collections.MutableSet
+            as the latter are deprecated in Python 3.7 and are due to be removed in Python 3.8.
+            The classes in collections.abc.* are available from Python 3.3 onwards. If you
+            require support for Python 3.2, then copy the pyabc.i file and modify by removing
+            the few instances of the .abc sub-module.
+
+            *** POTENTIAL INCOMPATIBILITY ***
+
 2018-06-12: olly,wsfulton
             [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1.
 
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index f3550ba..799342f 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -6426,7 +6426,8 @@
 <p>
 By including <tt>pyabc.i</tt> and using the <tt>-py3</tt> command
 line option when calling SWIG, the proxy classes of the STL containers
-will automatically gain an appropriate abstract base class. For
+will automatically gain an appropriate abstract base class from the
+<tt>collections.abc</tt> module. For
 example, the following SWIG interface:
 </p>
 
@@ -6443,8 +6444,8 @@
 
 <p>
 will generate a Python proxy class <tt>Mapii</tt> inheriting from
-<tt>collections.MutableMap</tt> and a proxy class <tt>IntList</tt>
-inheriting from <tt>collections.MutableSequence</tt>.
+<tt>collections.abc.MutableMap</tt> and a proxy class <tt>IntList</tt>
+inheriting from <tt>collections.abc.MutableSequence</tt>.
 </p>
 
 <p>
@@ -6453,7 +6454,7 @@
 </p>
 
 <div class="code"><pre>
-%pythonabc(MySet, collections.MutableSet);
+%pythonabc(MySet, collections.abc.MutableSet);
 </pre></div>
 
 <p>
@@ -6461,6 +6462,14 @@
 <a href="https://www.python.org/dev/peps/pep-3119/">PEP 3119</a>.
 </p>
 
+<p>
+<b>Compatibility Note:</b> SWIG-4.0.0 changed the base classes to use the
+<tt>collections.abc</tt> module instead of <tt>collections</tt> due to the deprecation
+of the classes in the <tt>collections</tt> module in Python 3.7.
+The <tt>collections.abc</tt> module was introduced in Python 3.3 and hence this feature
+requires Python 3.3 or later.
+</p>
+
 <H3><a name="Python_nn77">38.12.4 Byte string output conversion</a></H3>
 
 
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index 4fdc799..9f99dcb 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -1,5 +1,11 @@
+import sys
+
+# collections.abc requires Python 3.3+
+if sys.version_info[0:2] < (3, 3):
+    exit(0)
+
 from python_abstractbase import *
-from collections import *
+import collections.abc
 
 # This is expected to fail with -builtin option
 # Builtin types can't inherit from pure-python abstract bases
@@ -10,12 +16,16 @@
 if not is_swig_py3:
     exit(0)
 
-assert issubclass(Mapii, MutableMapping)
-assert issubclass(Multimapii, MutableMapping)
-assert issubclass(IntSet, MutableSet)
-assert issubclass(IntMultiset, MutableSet)
-assert issubclass(IntVector, MutableSequence)
-assert issubclass(IntList, MutableSequence)
+def check_issubclass(derived, base):
+    if not issubclass(derived, base):
+        raise RuntimeError("{} is not a subclass of {}".format(derived, base))
+
+check_issubclass(Mapii, collections.abc.MutableMapping)
+check_issubclass(Multimapii, collections.abc.MutableMapping)
+check_issubclass(IntSet, collections.abc.MutableSet)
+check_issubclass(IntMultiset, collections.abc.MutableSet)
+check_issubclass(IntVector, collections.abc.MutableSequence)
+check_issubclass(IntList, collections.abc.MutableSequence)
 
 mapii = Mapii()
 multimapii = Multimapii()
diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i
index 12ce659..fbd91dc 100644
--- a/Lib/python/pyabc.i
+++ b/Lib/python/pyabc.i
@@ -1,10 +1,10 @@
 %define %pythonabc(Type, Abc)
   %feature("python:abc", #Abc) Type;
 %enddef
-%pythoncode %{import collections%}
-%pythonabc(std::vector, collections.MutableSequence);
-%pythonabc(std::list, collections.MutableSequence);
-%pythonabc(std::map, collections.MutableMapping);
-%pythonabc(std::multimap, collections.MutableMapping);
-%pythonabc(std::set, collections.MutableSet);
-%pythonabc(std::multiset, collections.MutableSet);
+%pythoncode %{import collections.abc%}
+%pythonabc(std::vector, collections.abc.MutableSequence);
+%pythonabc(std::list, collections.abc.MutableSequence);
+%pythonabc(std::map, collections.abc.MutableMapping);
+%pythonabc(std::multimap, collections.abc.MutableMapping);
+%pythonabc(std::set, collections.abc.MutableSet);
+%pythonabc(std::multiset, collections.abc.MutableSet);