diff options
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/SCons/Platform/__init__.py | 9 | ||||
| -rw-r--r-- | src/engine/SCons/compat/__init__.py | 35 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 964ed67..5bcd91c 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -44,6 +44,8 @@ their own platform definition. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.compat + import imp import os import string @@ -176,8 +178,8 @@ class TempFileMunge: # We use the .lnk suffix for the benefit of the Phar Lap # linkloc linker, which likes to append an .lnk suffix if # none is given. - tmp = os.path.normpath(tempfile.mktemp('.lnk')) - native_tmp = SCons.Util.get_native_path(tmp) + (fd, tmp) = tempfile.mkstemp('.lnk', text=True) + native_tmp = SCons.Util.get_native_path(os.path.normpath(tmp)) if env['SHELL'] and env['SHELL'] == 'sh': # The sh shell will try to escape the backslashes in the @@ -197,7 +199,8 @@ class TempFileMunge: prefix = '@' args = map(SCons.Subst.quote_spaces, cmd[1:]) - open(tmp, 'w').write(string.join(args, " ") + "\n") + os.write(fd, string.join(args, " ") + "\n") + os.close(fd) # XXX Using the SCons.Action.print_actions value directly # like this is bogus, but expedient. This class should # really be rewritten as an Action that defines the diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 2a86324..553fcf3 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -250,6 +250,41 @@ except ImportError: # Pre-1.6 Python has no UserString module. import_as('_scons_UserString', 'UserString') +import tempfile +try: + tempfile.mkstemp +except AttributeError: + # Pre-2.3 Python has no tempfile.mkstemp function, so try to simulate it. + # adapted from the mkstemp implementation in python 3. + import os + import errno + def mkstemp( *args, **kw ) : + text = False + if 'text' in kw : + text = kw['text'] + del kw['text'] + elif len( args ) == 4 : + text = args[3] + args = args[:3] + flags = os.O_RDWR | os.O_CREAT | os.O_EXCL + if not text and hasattr( os, 'O_BINARY' ) : + flags |= os.O_BINARY + while True: + try : + name = tempfile.mktemp( *args, **kw ) + fd = os.open( name, flags, 0600 ) + return (fd, os.path.abspath(name)) + except OSError, e: + if e.errno == errno.EEXIST: + continue + raise + + tempfile.mkstemp = mkstemp + del mkstemp + + + + # Local Variables: # tab-width:4 # indent-tabs-mode:nil |
