Add compat "collections" module for pre-2.4 Python verseions. For now.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 11 Apr 2010 14:09:56 +0000 (14:09 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 11 Apr 2010 14:09:56 +0000 (14:09 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4779 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/MANIFEST.in
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Platform/PlatformTests.py
src/engine/SCons/Scanner/CTests.py
src/engine/SCons/Scanner/LaTeXTests.py
src/engine/SCons/Scanner/ScannerTests.py
src/engine/SCons/compat/__init__.py
src/engine/SCons/compat/_scons_collections.py [new file with mode: 0644]

index ec5e32c0dbe91cda9cbe09cda9dcbecefc31a2f9..576c82cde51ba85677c2e948fedfaf0bf2282133 100644 (file)
@@ -2,6 +2,7 @@ SCons/__init__.py
 SCons/Action.py
 SCons/Builder.py
 SCons/compat/__init__.py
+SCons/compat/_scons_collections.py
 SCons/compat/_scons_hashlib.py
 SCons/compat/_scons_io.py
 SCons/compat/_scons_itertools.py
index 8c3dbe855ac53a8b563fd91e83905ddced3fe8e3..5f1b4b0908b3ab81f166d013342bbce8cfad2239 100644 (file)
@@ -24,6 +24,8 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import collections
 import os
 import re
index 464dd0233cea74d368579dca415cf6714caaed50..6841272db98d8fca83c58bb03b7811531aad4798 100644 (file)
@@ -23,6 +23,8 @@
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import collections
 import sys
 import unittest
index acbfe5036fca6ebcdd6bc86d22a653463ee1c17b..34e3163dbaa9470542e45991c8490246ca266c1d 100644 (file)
@@ -23,6 +23,8 @@
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import collections
 import os
 import sys
index afc17cff5dae4c8cf35a24c57d13d60e1bf9aebe..8cea63fa9003571e2e67807e886c65812682156c 100644 (file)
@@ -23,6 +23,8 @@
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import collections
 import os
 import sys
index cec89f48e0a6e296eecab10d3727b31fdeb8d433..922c2213cd4e0821b845b787ea5e6a9c3fd16f84 100644 (file)
@@ -24,6 +24,8 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import collections
 import sys
 import unittest
index f220c32400a7fbe8b8769187a07ee659fe51818b..cc14b92aa19e4f610bdcdd4f581913088c4be03a 100644 (file)
@@ -97,25 +97,30 @@ except NameError:
     __builtin__.set = sets.Set
 
 
-import collections
 try:
-    collections.UserDict
-except AttributeError:
-    import UserDict
-    collections.UserDict = UserDict.UserDict
-    del UserDict
-try:
-    collections.UserList
-except AttributeError:
-    import UserList
-    collections.UserList = UserList.UserList
-    del UserList
-try:
-    collections.UserString
-except AttributeError:
-    import UserString
-    collections.UserString = UserString.UserString
-    del UserString
+    import collections
+except ImportError:
+    # Pre-2.4 Python has no collections module.
+    import_as('_scons_collections', 'collections')
+else:
+    try:
+        collections.UserDict
+    except AttributeError:
+        import UserDict
+        collections.UserDict = UserDict.UserDict
+        del UserDict
+    try:
+        collections.UserList
+    except AttributeError:
+        import UserList
+        collections.UserList = UserList.UserList
+        del UserList
+    try:
+        collections.UserString
+    except AttributeError:
+        import UserString
+        collections.UserString = UserString.UserString
+        del UserString
 
 
 import fnmatch
diff --git a/src/engine/SCons/compat/_scons_collections.py b/src/engine/SCons/compat/_scons_collections.py
new file mode 100644 (file)
index 0000000..80832b7
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__doc__ = """
+collections compatibility module for older (pre-2.4) Python versions
+
+This does not not NOT (repeat, *NOT*) provide complete collections
+functionality.  It only wraps the portions of collections functionality
+used by SCons, in an interface that looks enough like collections for
+our purposes.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from UserDict import UserDict
+from UserList import UserList
+from UserString import UserString
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: