Issue 2334: Use compatibility versions of collections.User{Dict,List,String}
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 7 Apr 2010 15:29:39 +0000 (15:29 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 7 Apr 2010 15:29:39 +0000 (15:29 +0000)
instead of the deprecated User{Dict,List,String} modules.  The two test
scripts that use User{List,String} fall back on ImportError by hand.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4775 fdb21ef1-2011-0410-befe-b5e4ea1792b1

27 files changed:
src/engine/SCons/ActionTests.py
src/engine/SCons/Builder.py
src/engine/SCons/BuilderTests.py
src/engine/SCons/DefaultsTests.py
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
src/engine/SCons/Executor.py
src/engine/SCons/Node/Alias.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/__init__.py
src/engine/SCons/Platform/PlatformTests.py
src/engine/SCons/Scanner/CTests.py
src/engine/SCons/Scanner/LaTeXTests.py
src/engine/SCons/Scanner/RCTests.py
src/engine/SCons/Scanner/ScannerTests.py
src/engine/SCons/Script/SConscript.py
src/engine/SCons/Script/__init__.py
src/engine/SCons/Subst.py
src/engine/SCons/SubstTests.py
src/engine/SCons/Util.py
src/engine/SCons/UtilTests.py
src/engine/SCons/Variables/ListVariable.py
src/engine/SCons/compat/__init__.py
src/engine/SCons/compat/_scons_UserString.py [deleted file]
test/SConscript/SConscript.py
test/subclassing.py

index 6b8b465d692a791585b3abe68e4a68575313b123..4cb5a0ab40c6cbc963be608cab73ac4424dad5b0 100644 (file)
@@ -36,13 +36,13 @@ class GlobalActFunc:
     def __call__(self):
         pass
 
+import collections
 import io
 import os
 import re
 import sys
 import types
 import unittest
-import UserDict
 
 import SCons.Action
 import SCons.Environment
index c999afdd0b8fbd59ebec0a89024e19c3c8d7697c..4cce92f9f47dccd774a95146cc8b1290dff05e51 100644 (file)
@@ -101,8 +101,7 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import UserDict
-import UserList
+import collections
 
 import SCons.Action
 from SCons.Debug import logInstanceCreation
@@ -200,7 +199,7 @@ class DictEmitter(SCons.Util.Selector):
             target, source = emitter(target, source, env)
         return (target, source)
 
-class ListEmitter(UserList.UserList):
+class ListEmitter(collections.UserList):
     """A callable list of emitters that calls each in sequence,
     returning the result.
     """
@@ -218,7 +217,7 @@ misleading_keywords = {
     'sources'   : 'source',
 }
 
-class OverrideWarner(UserDict.UserDict):
+class OverrideWarner(collections.UserDict):
     """A class for warning about keyword arguments that we use as
     overrides in a Builder call.
 
@@ -227,7 +226,7 @@ class OverrideWarner(UserDict.UserDict):
     warnings once, no matter how many Builders are invoked.
     """
     def __init__(self, dict):
-        UserDict.UserDict.__init__(self, dict)
+        collections.UserDict.__init__(self, dict)
         if __debug__: logInstanceCreation(self, 'Builder.OverrideWarner')
         self.already_warned = None
     def warn(self):
index de6d2be9b95ac6569764bab5a6062884a7f19f9a..38eb0cacf65818cbabbfb67625db3fd04b4cd15b 100644 (file)
@@ -32,12 +32,12 @@ import SCons.compat
 def Func():
     pass
 
+import collections
 import io
 import os.path
 import re
 import sys
 import unittest
-import UserList
 
 import TestCmd
 
@@ -253,7 +253,7 @@ class BuilderTestCase(unittest.TestCase):
         assert not hasattr(n2, 'env')
 
         l = [1]
-        ul = UserList.UserList([2])
+        ul = collections.UserList([2])
         try:
             l.extend(ul)
         except TypeError:
@@ -707,7 +707,7 @@ class BuilderTestCase(unittest.TestCase):
         assert env['CNT'][0] == 2
         tgts = builder(env, None, infiles[2:4])
         try:
-            [].extend(UserList.UserList())
+            [].extend(collections.UserList())
         except TypeError:
             # Old Python version (1.5.2) that can't handle extending
             # a list with list-like objects.  That means the return
index 99cb120b5ff2dbf12d40d8322e8fa130612e9767..96d5de7afe9bbcfeba5a7ddc4df530f611d12d90 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import SCons.compat
+
 import os
 import os.path
 import StringIO
 import sys
 import unittest
 
-from UserDict import UserDict
+from collections import UserDict
 
 import TestCmd
 
index 1fd763d322bc5840d5c066f52e629c952eeb9efe..5449669e08d1b7553040bc80ff9c7386e97ef509 100644 (file)
@@ -41,7 +41,7 @@ import os
 import sys
 import re
 import shlex
-from UserDict import UserDict
+from collections import UserDict
 
 import SCons.Action
 import SCons.Builder
index 3a2cd8a96a46ca6484af168404f6f8b73e4d1b24..0719853b3a402064ea2d06321c8ae6b3b5004ddc 100644 (file)
@@ -25,13 +25,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import SCons.compat
 
+import collections
 import copy
 import io
 import os
 import sys
 import TestCmd
 import unittest
-import UserList
 
 from SCons.Environment import *
 import SCons.Warnings
@@ -126,15 +126,15 @@ class Scanner:
 
 
 
-class CLVar(UserList.UserList):
+class CLVar(collections.UserList):
     def __init__(self, seq):
         if isinstance(seq, str):
             seq = seq.split()
-        UserList.UserList.__init__(self, seq)
+        collections.UserList.__init__(self, seq)
     def __add__(self, other):
-        return UserList.UserList.__add__(self, CLVar(other))
+        return collections.UserList.__add__(self, CLVar(other))
     def __radd__(self, other):
-        return UserList.UserList.__radd__(self, CLVar(other))
+        return collections.UserList.__radd__(self, CLVar(other))
     def __coerce__(self, other):
         return (self, CLVar(other))
 
@@ -1480,9 +1480,9 @@ def exists(env):
         assert b1 == b2, diff_dict(b1, b2)
 
         import UserDict
-        UD = UserDict.UserDict
+        UD = collections.UserDict
         import UserList
-        UL = UserList.UserList
+        UL = collections.UserList
 
         cases = [
             'a1',       'A1',           'a1A1',
@@ -2152,9 +2152,9 @@ f5: \
         """Test prepending to construction variables in an Environment
         """
         import UserDict
-        UD = UserDict.UserDict
+        UD = collections.UserDict
         import UserList
-        UL = UserList.UserList
+        UL = collections.UserList
 
         cases = [
             'a1',       'A1',           'A1a1',
index aaf71b8d5f1ab8a6922c61e1ff6f3760c973e798..8f9b917d9c9420edd7dc5457b51a9feb520fce26 100644 (file)
@@ -31,7 +31,7 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import UserList
+import collections
 
 from SCons.Debug import logInstanceCreation
 import SCons.Errors
@@ -47,15 +47,15 @@ class Batch:
 
 
 
-class TSList(UserList.UserList):
+class TSList(collections.UserList):
     """A class that implements $TARGETS or $SOURCES expansions by wrapping
     an executor Method.  This class is used in the Executor.lvars()
     to delay creation of NodeList objects until they're needed.
 
-    Note that we subclass UserList.UserList purely so that the
+    Note that we subclass collections.UserList purely so that the
     is_Sequence() function will identify an object of this class as
     a list during variable expansion.  We're not really using any
-    UserList.UserList methods in practice.
+    collections.UserList methods in practice.
     """
     def __init__(self, func):
         self.func = func
index 521488e6d77b972d6cc81fd8a23ed3ba087fe4cf..f817356c3a142a108669456985768b296e6a794a 100644 (file)
@@ -32,13 +32,13 @@ This creates a hash of global Aliases (dummy targets).
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import UserDict
+import collections
 
 import SCons.Errors
 import SCons.Node
 import SCons.Util
 
-class AliasNameSpace(UserDict.UserDict):
+class AliasNameSpace(collections.UserDict):
     def Alias(self, name, **kw):
         if isinstance(name, SCons.Node.Alias.Alias):
             return name
index 8e581f129911b35b9057d9e41ecca0fab51ca5e3..01ceb5118a2cfeb41e45f8845eb2b60b61ded872 100644 (file)
@@ -2820,8 +2820,8 @@ class RepositoryTestCase(_tempdirTestCase):
         try:
             eval('test_string = u"Con\x1aTents\n"')
         except SyntaxError:
-            import UserString
-            class FakeUnicodeString(UserString.UserString):
+            import collections
+            class FakeUnicodeString(collections.UserString):
                 def encode(self, encoding):
                     return str(self)
             test_string = FakeUnicodeString("Con\x1aTents\n")
index 9c5973c4283b308e22440e6a38f8a02cbe221f2a..8c3dbe855ac53a8b563fd91e83905ddced3fe8e3 100644 (file)
@@ -24,11 +24,11 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import os
 import re
 import sys
 import unittest
-import UserList
 
 import SCons.Errors
 import SCons.Node
@@ -1274,7 +1274,7 @@ class NodeListTestCase(unittest.TestCase):
         nl = SCons.Node.NodeList([n3, n2, n1])
 
         l = [1]
-        ul = UserList.UserList([2])
+        ul = collections.UserList([2])
         try:
             l.extend(ul)
         except TypeError:
index d7846c5401aaf8e495c0b5f5f61e088af2e9bc1b..472f99f04866f62e83351a3633320792c888dd29 100644 (file)
@@ -45,9 +45,9 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import copy
 from itertools import chain, izip
-import UserList
 
 from SCons.Debug import logInstanceCreation
 import SCons.Executor
@@ -1255,7 +1255,7 @@ class Node:
             return ( ' '*11).join(lines)
 
 try:
-    [].extend(UserList.UserList([]))
+    [].extend(collections.UserList([]))
 except TypeError:
     # Python 1.5.2 doesn't allow a list to be extended by list-like
     # objects (such as UserList instances), so just punt and use
@@ -1263,7 +1263,7 @@ except TypeError:
     def NodeList(l):
         return l
 else:
-    class NodeList(UserList.UserList):
+    class NodeList(collections.UserList):
         def __str__(self):
             return str(list(map(str, self.data)))
 
index 59d7e7154a195ffa8615fccba6aeab70af668c26..464dd0233cea74d368579dca415cf6714caaed50 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import sys
 import unittest
 
 import SCons.Errors
 import SCons.Platform
-import UserDict
 
-class Environment(UserDict.UserDict):
+class Environment(collections.UserDict):
     def Detect(self, cmd):
         return cmd
     def AppendENVPath(self, key, value):
index 2869d3be145f4471d8f3897a845ce7d3fd36b241..acbfe5036fca6ebcdd6bc86d22a653463ee1c17b 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import os
-import os.path
 import sys
 import TestCmd
 import unittest
-import UserDict
 
 import SCons.Node.FS
 import SCons.Warnings
@@ -170,9 +169,9 @@ test.write("f5b.h", "\n")
 
 # define some helpers:
 
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
     def __init__(self, **kw):
-        UserDict.UserDict.__init__(self)
+        collections.UserDict.__init__(self)
         self.data.update(kw)
         self.fs = SCons.Node.FS.FS(test.workpath(''))
 
index 4ded0b8444a68511715ce443fd56879200cf2d41..afc17cff5dae4c8cf35a24c57d13d60e1bf9aebe 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import os.path
+import collections
+import os
 import sys
 import unittest
-import UserDict
 
 import TestCmd
 import SCons.Node.FS
@@ -64,9 +64,9 @@ test.write('incNO.tex', "\n")
 
 # define some helpers:
 #   copied from CTest.py
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
     def __init__(self, **kw):
-        UserDict.UserDict.__init__(self)
+        collections.UserDict.__init__(self)
         self.data.update(kw)
         self.fs = SCons.Node.FS.FS(test.workpath(''))
 
index 60af3b4fa37a8583be12f153724ade1a02b5f480..2d97df518205ad4ba9d01f75d96efc576c2a76b2 100644 (file)
@@ -27,11 +27,10 @@ import TestCmd
 import SCons.Scanner.RC
 import unittest
 import sys
+import collections
 import os
-import os.path
 import SCons.Node.FS
 import SCons.Warnings
-import UserDict
 
 test = TestCmd.TestCmd(workdir = '')
 
@@ -71,9 +70,9 @@ for h in headers:
 
 # define some helpers:
 
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
     def __init__(self,**kw):
-        UserDict.UserDict.__init__(self)
+        collections.UserDict.__init__(self)
         self.data.update(kw)
         self.fs = SCons.Node.FS.FS(test.workpath(''))
         
index 500ce1ae338e4854a09cbca450968afc5a8a9fa2..cec89f48e0a6e296eecab10d3727b31fdeb8d433 100644 (file)
@@ -24,9 +24,9 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import sys
 import unittest
-import UserDict
 
 import SCons.Scanner
 
@@ -34,9 +34,9 @@ class DummyFS:
     def File(self, name):
         return DummyNode(name)
 
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
     def __init__(self, dict=None, **kw):
-        UserDict.UserDict.__init__(self, dict)
+        collections.UserDict.__init__(self, dict)
         self.data.update(kw)
         self.fs = DummyFS()
     def subst(self, strSubst, target=None, source=None, conv=None):
index c55d22038b3ebb3c514c5b4d6ee5c0884406b9a5..4e4338298e46b5def0ff134f0fe0f944cceb354e 100644 (file)
@@ -46,12 +46,12 @@ import SCons.Script.Main
 import SCons.Tool
 import SCons.Util
 
+import collections
 import os
 import os.path
 import re
 import sys
 import traceback
-import UserList
 
 # The following variables used to live in this module.  Some
 # SConscript files out there may have referred to them directly as
index 7763210aebf67392e9bbaf85f86de10030b133e9..465508cba5975b85a2b1e8840815f896af4548d7 100644 (file)
@@ -39,9 +39,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import time
 start_time = time.time()
 
+import collections
 import os
 import sys
-import UserList
 
 # Special chicken-and-egg handling of the "--debug=memoizer" flag:
 #
@@ -183,7 +183,7 @@ CScan                   = SCons.Defaults.CScan
 DefaultEnvironment      = SCons.Defaults.DefaultEnvironment
 
 # Other variables we provide.
-class TargetList(UserList.UserList):
+class TargetList(collections.UserList):
     def _do_nothing(self, *args, **kw):
         pass
     def _add_Default(self, list):
index 9888e8db782d9c5c57e4e962d856fa7a4927072a..a0a48597601961d4630effdab0530b5d119bc198 100644 (file)
@@ -30,9 +30,8 @@ from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import collections
 import re
-import UserList
-import UserString
 
 import SCons.Errors
 
@@ -120,7 +119,7 @@ def quote_spaces(arg):
     else:
         return str(arg)
 
-class CmdStringHolder(UserString.UserString):
+class CmdStringHolder(collections.UserString):
     """This is a special class used to hold strings generated by
     scons_subst() and scons_subst_list().  It defines a special method
     escape().  When passed a function with an escape algorithm for a
@@ -128,7 +127,7 @@ class CmdStringHolder(UserString.UserString):
     proper escape sequences inserted.
     """
     def __init__(self, cmd, literal=None):
-        UserString.UserString.__init__(self, cmd)
+        collections.UserString.__init__(self, cmd)
         self.literal = literal
 
     def is_literal(self):
@@ -195,15 +194,15 @@ class NLWrapper:
     _create_nodelist = _gen_nodelist
     
 
-class Targets_or_Sources(UserList.UserList):
+class Targets_or_Sources(collections.UserList):
     """A class that implements $TARGETS or $SOURCES expansions by in turn
     wrapping a NLWrapper.  This class handles the different methods used
     to access the list, calling the NLWrapper to create proxies on demand.
 
-    Note that we subclass UserList.UserList purely so that the
+    Note that we subclass collections.UserList purely so that the
     is_Sequence() function will identify an object of this class as
     a list during variable expansion.  We're not really using any
-    UserList.UserList methods in practice.
+    collections.UserList methods in practice.
     """
     def __init__(self, nl):
         self.nl = nl
@@ -594,7 +593,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv
 #        Subst_List_Strings[strSubst] = 1
 #    import SCons.Debug
 #    SCons.Debug.caller_trace(1)
-    class ListSubber(UserList.UserList):
+    class ListSubber(collections.UserList):
         """A class to construct the results of a scons_subst_list() call.
 
         Like StringSubber, this class binds a specific construction
@@ -611,7 +610,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv
         internally.
         """
         def __init__(self, env, mode, conv, gvars):
-            UserList.UserList.__init__(self, [])
+            collections.UserList.__init__(self, [])
             self.env = env
             self.mode = mode
             self.conv = conv
@@ -734,7 +733,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv
             """Arrange for the next word to start a new line.  This
             is like starting a new word, except that we have to append
             another line to the result."""
-            UserList.UserList.append(self, [])
+            collections.UserList.append(self, [])
             self.next_word()
 
         def this_word(self):
index 2eb91cae0ab5dda7144c82c74cdb5c8bdbca2e47..b423fa4e855106748181a1f811e217c375c05f5e 100644 (file)
@@ -31,7 +31,7 @@ import StringIO
 import sys
 import unittest
 
-from UserDict import UserDict
+from collections import UserDict
 
 import SCons.Errors
 
@@ -208,7 +208,7 @@ class SubstTestCase(unittest.TestCase):
         'T'         : ('x', 'y'),
         'CS'        : cs,
         'CL'        : cl,
-        'US'        : UserString.UserString('us'),
+        'US'        : collections.UserString('us'),
 
         # Test function calls within ${}.
         'FUNCCALL'  : '${FUNC1("$AAA $FUNC2 $BBB")}',
@@ -366,9 +366,9 @@ class scons_subst_TestCase(SubstTestCase):
         '$CL',                  'cl',
 
         # Various uses of UserString.
-        UserString.UserString('x'),         'x',
-        UserString.UserString('$X'),        'x',
-        UserString.UserString('$US'),       'us',
+        collections.UserString('x'),         'x',
+        collections.UserString('$X'),        'x',
+        collections.UserString('$US'),       'us',
         '$US',                              'us',
 
         # Test function calls within ${}.
@@ -758,12 +758,12 @@ class scons_subst_list_TestCase(SubstTestCase):
         ['$CL'],                [['cl']],
 
         # Various uses of UserString.
-        UserString.UserString('x'),         [['x']],
-        [UserString.UserString('x')],       [['x']],
-        UserString.UserString('$X'),        [['x']],
-        [UserString.UserString('$X')],      [['x']],
-        UserString.UserString('$US'),       [['us']],
-        [UserString.UserString('$US')],     [['us']],
+        collections.UserString('x'),         [['x']],
+        [collections.UserString('x')],       [['x']],
+        collections.UserString('$X'),        [['x']],
+        [collections.UserString('$X')],      [['x']],
+        collections.UserString('$US'),       [['us']],
+        [collections.UserString('$US')],     [['us']],
         '$US',                              [['us']],
         ['$US'],                            [['us']],
 
index 4ada27361880149dffd0448a0b47cb9c6f746ad7..e88a90b759e7e45b44fe845bf9782c1cf5f4f172 100644 (file)
@@ -36,9 +36,7 @@ import re
 import sys
 import types
 
-from UserDict import UserDict
-from UserList import UserList
-from UserString import UserString
+from collections import UserDict, UserList, UserString
 
 # Don't "from types import ..." these because we need to get at the
 # types module later to look for UnicodeType.
index fd7862c791924d3b939cc79cf80fba7dfda61025..e044065362854d0bb63557f4108c862a6d4a3ad7 100644 (file)
@@ -25,13 +25,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import SCons.compat
 
+import collections
 import io
 import os
-import os.path
 import sys
 import unittest
 
-from UserDict import UserDict
 
 import TestCmd
 
@@ -208,7 +207,7 @@ class UtilTestCase(unittest.TestCase):
 
     def test_is_Dict(self):
         assert is_Dict({})
-        assert is_Dict(UserDict())
+        assert is_Dict(collections.UserDict())
         try:
             class mydict(dict):
                 pass
@@ -225,7 +224,7 @@ class UtilTestCase(unittest.TestCase):
     def test_is_List(self):
         assert is_List([])
         import UserList
-        assert is_List(UserList.UserList())
+        assert is_List(collections.UserList())
         try:
             class mylist(list):
                 pass
@@ -248,7 +247,7 @@ class UtilTestCase(unittest.TestCase):
         except:
             pass
         else:
-            assert is_String(UserString.UserString(''))
+            assert is_String(collections.UserString(''))
         try:
             class mystr(str):
                 pass
@@ -284,18 +283,18 @@ class UtilTestCase(unittest.TestCase):
         try:
             import UserString
 
-            s1=UserString.UserString('blah')
+            s1=collections.UserString('blah')
             assert to_String(s1) == s1, s1
             assert to_String(s1) == 'blah', s1
 
-            class Derived(UserString.UserString):
+            class Derived(collections.UserString):
                 pass
             s2 = Derived('foo')
             assert to_String(s2) == s2, s2
             assert to_String(s2) == 'foo', s2
 
             if HasUnicode:
-                s3=UserString.UserString(unicode('bar'))
+                s3=collections.UserString(unicode('bar'))
                 assert to_String(s3) == s3, s3
                 assert to_String(s3) == unicode('bar'), s3
                 assert isinstance(to_String(s3), unicode), \
@@ -619,7 +618,7 @@ class UtilTestCase(unittest.TestCase):
         s['c'] = 'CCC'
         assert s['c'] == 'CCC', s['c']
 
-        class DummyEnv(UserDict):
+        class DummyEnv(collections.UserDict):
             def subst(self, key):
                 if key[0] == '$':
                     return self[key[1:]]
index 5980f331a0e9ac433c5a2f7f46352e14f92c6c62..6cab09121c629fafe4b33166289ddc7d26b1d6af 100644 (file)
@@ -55,14 +55,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 __all__ = ['ListVariable',]
 
-import UserList
+import collections
 
 import SCons.Util
 
 
-class _ListVariable(UserList.UserList):
+class _ListVariable(collections.UserList):
     def __init__(self, initlist=[], allowedElems=[]):
-        UserList.UserList.__init__(self, [_f for _f in initlist if _f])
+        collections.UserList.__init__(self, [_f for _f in initlist if _f])
         self.allowedElems = sorted(allowedElems)
 
     def __cmp__(self, other):
index 0b70c5d16d0efc549087a412e5e9f26ee71e5d21..7e93a71efa73355a7d493a5082a4876fabb1aef1 100644 (file)
@@ -96,6 +96,28 @@ except NameError:
     import __builtin__, sets
     __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 fnmatch
 try:
     fnmatch.filter
@@ -267,11 +289,6 @@ except AttributeError:
     # Wrapping sys in () is silly, but protects it from 2to3 renames fixer
     sys.maxsize = (sys).maxint
 
-try:
-    import UserString
-except ImportError:
-    # Pre-1.6 Python has no UserString module.
-    import_as('_scons_UserString', 'UserString')
 
 import tempfile
 try:
diff --git a/src/engine/SCons/compat/_scons_UserString.py b/src/engine/SCons/compat/_scons_UserString.py
deleted file mode 100644 (file)
index 59be10b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# __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.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-__doc__ = """
-A user-defined wrapper around string objects
-
-This class is "borrowed" from the Python 2.2 UserString and modified
-slightly for use with SCons.  It is *NOT* guaranteed to be fully compliant
-with the standard UserString class from all later versions of Python.
-In particular, it does not necessarily contain all of the methods found
-in later versions.
-"""
-
-try: unicode
-except NameError:
-    def is_String(obj):
-        return isinstance(obj, str)
-else:
-    def is_String(obj):
-        return type(obj) in (str, unicode)
-
-class UserString:
-    def __init__(self, seq):
-        if is_String(seq):
-            self.data = seq
-        elif isinstance(seq, UserString):
-            self.data = seq.data[:]
-        else:
-            self.data = str(seq)
-    def __str__(self): return str(self.data)
-    def __repr__(self): return repr(self.data)
-    def __int__(self): return int(self.data)
-    def __long__(self): return long(self.data)
-    def __float__(self): return float(self.data)
-    def __complex__(self): return complex(self.data)
-    def __hash__(self): return hash(self.data)
-
-    def __cmp__(self, str):
-        if isinstance(string, UserString):
-            return cmp(self.data, str.data)
-        else:
-            return cmp(self.data, string)
-    def __contains__(self, char):
-        return char in self.data
-
-    def __len__(self): return len(self.data)
-    def __getitem__(self, index): return self.__class__(self.data[index])
-    def __getslice__(self, start, end):
-        start = max(start, 0); end = max(end, 0)
-        return self.__class__(self.data[start:end])
-
-    def __add__(self, other):
-        if isinstance(other, UserString):
-            return self.__class__(self.data + other.data)
-        elif is_String(other):
-            return self.__class__(self.data + other)
-        else:
-            return self.__class__(self.data + str(other))
-    def __radd__(self, other):
-        if is_String(other):
-            return self.__class__(other + self.data)
-        else:
-            return self.__class__(str(other) + self.data)
-    def __mul__(self, n):
-        return self.__class__(self.data*n)
-    __rmul__ = __mul__
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
index 5bd49f3e71fea318ba9e06c2b0ff71bc6269a4d5..177b5dfdebce959bff8f20d6ff3ac3a07612b56e 100644 (file)
@@ -71,10 +71,13 @@ assert foo == "subdir/SConscript foo"
 
 SConscript('SConscript5')
 
-import UserList
+try:
+    from io import UserList
+except ImportError:
+    from UserList import UserList
 x7 = "SConstruct x7"
 x8 = "SConstruct x8"
-x9 = SConscript('SConscript6', UserList.UserList(["x7", "x8"]))
+x9 = SConscript('SConscript6', UserList(["x7", "x8"]))
 assert x9 == "SConscript6 x9", x9
 
 SConscript('SConscript7')
index 655de5191a0bfd4a87f9e0db829416a566cb8fae..fc003498ff05a65b9cff16d8f6fa3e4bd1822316 100644 (file)
@@ -51,7 +51,10 @@ class my_Environment(Environment):
 env = my_Environment()
 env.Command('f0.out', 'f0.in', copy_action)
 
-from UserString import UserString
+try:
+    from io import UserString
+except ImportError:
+    from UserString import UserString
 try:
     class mystr(str):
         pass