diff options
Diffstat (limited to 'src/engine/SCons/compat/__init__.py')
-rw-r--r-- | src/engine/SCons/compat/__init__.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 0dfb18e..5e095d1 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -60,7 +60,7 @@ _scons_subprocess.py is our compatibility module for subprocess) so that we can still try to import the real module name and fall back to our compatibility module if we get an ImportError. The import_as() function defined below loads the module as the "real" name (without the -underscore), after which all of the "import {module}" statements in the +'_scons'), after which all of the "import {module}" statements in the rest of our code will find our pre-loaded compatibility module. """ @@ -80,6 +80,19 @@ def import_as(module, name): import builtins try: + import hashlib +except ImportError: + # Pre-2.5 Python has no hashlib module. + try: + import_as('_scons_hashlib', 'hashlib') + except ImportError: + # If we failed importing our compatibility module, it probably + # means this version of Python has no md5 module. Don't do + # anything and let the higher layer discover this fact, so it + # can fall back to using timestamp. + pass + +try: set except NameError: # Pre-2.4 Python has no native set type @@ -112,6 +125,25 @@ except ImportError: # Pre-2.3 Python has no optparse module. import_as('_scons_optparse', 'optparse') +import shlex +try: + shlex.split +except AttributeError: + # Pre-2.3 Python has no shlex.split function. + def split(s, comments=False): + import StringIO + lex = shlex.shlex(StringIO.StringIO(s)) + lex.wordchars = lex.wordchars + '/\\-+,=:' + result = [] + while True: + tt = lex.get_token() + if not tt: + break + result.append(tt) + return result + shlex.split = split + del split + try: import subprocess except ImportError: |