diff options
author | Steven Knight <knight@baldmt.com> | 2010-04-09 16:57:36 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2010-04-09 16:57:36 (GMT) |
commit | 608d04e42b0de175c29b806517d4a32a594fa493 (patch) | |
tree | 4db3d9b215364c3fa3ab0898eb87221b945d260b /src/engine/SCons/compat | |
parent | 06d4efdf2ef4d7adfbaad8266dca5862c8f421af (diff) | |
download | SCons-608d04e42b0de175c29b806517d4a32a594fa493.zip SCons-608d04e42b0de175c29b806517d4a32a594fa493.tar.gz SCons-608d04e42b0de175c29b806517d4a32a594fa493.tar.bz2 |
Issue 2330: For forward compatibility, use "import profile" and have
the SCons.compat layer import cProfile as profile when it's available.
Diffstat (limited to 'src/engine/SCons/compat')
-rw-r--r-- | src/engine/SCons/compat/__init__.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 7e93a71..4553d21 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -194,6 +194,20 @@ except AttributeError: try: + # Use the "imp" module to protect the import from fixers. + import imp + 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 + + +try: import platform except ImportError: # Pre-2.3 Python has no platform module. |