From: stevenknight Date: Tue, 13 Apr 2010 07:42:22 +0000 (+0000) Subject: Avoid 3.0 fixer issues by not using module names as variable names. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2cdb74c260cdb339e88c55f1621000bc2267fefc;p=scons.git Avoid 3.0 fixer issues by not using module names as variable names. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4782 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 2cec73d2..67d47eed 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -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: diff --git a/src/engine/SCons/compat/_scons_collections.py b/src/engine/SCons/compat/_scons_collections.py index 80832b7d..089f0aa0 100644 --- a/src/engine/SCons/compat/_scons_collections.py +++ b/src/engine/SCons/compat/_scons_collections.py @@ -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 diff --git a/src/engine/SCons/compat/_scons_io.py b/src/engine/SCons/compat/_scons_io.py index 784021dc..538afb77 100644 --- a/src/engine/SCons/compat/_scons_io.py +++ b/src/engine/SCons/compat/_scons_io.py @@ -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 diff --git a/src/engine/SCons/compat/_scons_shlex.py b/src/engine/SCons/compat/_scons_shlex.py index febaa990..dfca2c1d 100644 --- a/src/engine/SCons/compat/_scons_shlex.py +++ b/src/engine/SCons/compat/_scons_shlex.py @@ -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"]