Avoid 3.0 fixer issues by not using module names as variable names.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 13 Apr 2010 07:42:22 +0000 (07:42 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 13 Apr 2010 07:42:22 +0000 (07:42 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4782 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/compat/__init__.py
src/engine/SCons/compat/_scons_collections.py
src/engine/SCons/compat/_scons_io.py
src/engine/SCons/compat/_scons_shlex.py

index 2cec73d2a8f5bfed09840b82b0cd94956e5919b8..67d47eedb62bbbe2e67a1b7fb98decfc04da7a7e 100644 (file)
@@ -80,10 +80,10 @@ except ImportError:
     # Use the "imp" module to protect the import from fixers.
     import imp
     import sys
-    __builtin__ = imp.load_module('__builtin__',
-                                  *imp.find_module('__builtin__'))
-    sys.modules['builtins'] = __builtin__
-    del __builtin__
+    _builtin = imp.load_module('__builtin__',
+                               *imp.find_module('__builtin__'))
+    sys.modules['builtins'] = _builtin
+    del _builtin
 
 import _scons_builtins
 
@@ -116,24 +116,27 @@ except ImportError:
     # Pre-2.4 Python has no collections module.
     import_as('_scons_collections', 'collections')
 else:
+    # Use the "imp" module to protect the imports below from fixers.
+    import imp
     try:
         collections.UserDict
     except AttributeError:
-        import UserDict
-        collections.UserDict = UserDict.UserDict
-        del UserDict
+        _UserDict = imp.load_module('UserDict', *imp.find_module('UserDict'))
+        collections.UserDict = _UserDict.UserDict
+        del _UserDict
     try:
         collections.UserList
     except AttributeError:
-        import UserList
-        collections.UserList = UserList.UserList
-        del UserList
+        _UserList = imp.load_module('UserList', *imp.find_module('UserList'))
+        collections.UserList = _UserList.UserList
+        del _UserList
     try:
         collections.UserString
     except AttributeError:
-        import UserString
-        collections.UserString = UserString.UserString
-        del UserString
+        _UserString = imp.load_module('UserString',
+                                      *imp.find_module('UserString'))
+        collections.UserString = _UserString.UserString
+        del _UserString
 
 
 import fnmatch
@@ -214,29 +217,29 @@ except AttributeError:
 try:
     # Use the "imp" module to protect the import from fixers.
     import imp
-    cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
+    _cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
 except ImportError, e:
     # The "cPickle" module has already been eliminated in favor of
     # having "import pickle" import the fast version when available.
     pass
 else:
     import sys
-    sys.modules['pickle'] = cPickle
-    del cPickle
+    sys.modules['pickle'] = _cPickle
+    del _cPickle
 
 
 try:
     # Use the "imp" module to protect the import from fixers.
     import imp
-    cProfile = imp.load_module('cProfile', *imp.find_module('cProfile'))
+    _cProfile = imp.load_module('cProfile', *imp.find_module('cProfile'))
 except ImportError:
     # The "cProfile" module has already been eliminated in favor of
     # having "import profile" import the fast version when available.
     pass
 else:
     import sys
-    sys.modules['profile'] = cProfile
-    del cProfile
+    sys.modules['profile'] = _cProfile
+    del _cProfile
 
 
 try:
index 80832b7df499bc46ea063a4d954f73cfd26c5599..089f0aa09db7e1d845d48af79bb11fde4270cf5e 100644 (file)
@@ -32,9 +32,20 @@ our purposes.
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-from UserDict import UserDict
-from UserList import UserList
-from UserString import UserString
+# Use the "imp" module to protect the imports below from fixers.
+import imp
+
+_UserDict = imp.load_module('UserDict', *imp.find_module('UserDict'))
+_UserList = imp.load_module('UserList', *imp.find_module('UserList'))
+_UserString = imp.load_module('UserString', *imp.find_module('UserString'))
+
+UserDict = _UserDict.UserDict
+UserList = _UserList.UserList
+UserString = _UserString.UserString
+
+del _UserDict
+del _UserList
+del _UserString
 
 # Local Variables:
 # tab-width:4
index 784021dc9a7f570f996610912ac525b046c758a9..538afb77968c67f85ff1943cba96717c161a6279 100644 (file)
@@ -31,7 +31,12 @@ by SCons, in an interface that looks enough like io for our purposes.
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-from cStringIO import StringIO
+# Use the "imp" module to protect the imports below from fixers.
+import imp
+
+_cStringIO = imp.load_module('cStringIO', *imp.find_module('cStringIO'))
+StringIO = _cStringIO.StringIO
+del _cStringIO
 
 # Local Variables:
 # tab-width:4
index febaa9906c0ced6b8ebd2066287f0a7f13b5b521..dfca2c1d6e9a824605b17d4a3897f7c7eb1349c0 100644 (file)
@@ -7,6 +7,7 @@
 # Posix compliance, split(), string arguments, and
 # iterator interface by Gustavo Niemeyer, April 2003.
 
+import imp
 import os.path
 import sys
 #from collections import deque
@@ -31,10 +32,16 @@ else:
     def is_basestring(s):
         return isinstance(s, basestring)
 
+# Use the "imp" module to protect the imports below from fixers.
 try:
-    from cStringIO import StringIO
+    _cStringIO = imp.load_module('cStringIO', *imp.find_module('cStringIO'))
 except ImportError:
-    from StringIO import StringIO
+    _StringIO = imp.load_module('StringIO', *imp.find_module('StringIO'))
+    StringIO = _StringIO.StringIO
+    del _StringIO
+else:
+    StringIO = _cStringIO.StringIO
+    del _cStringIO
 
 __all__ = ["shlex", "split"]