]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Adding Python <= 2.2 support back in.
authorMarc-André Lemburg <mal@egenix.com>
Tue, 3 Dec 2002 08:45:11 +0000 (08:45 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Tue, 3 Dec 2002 08:45:11 +0000 (08:45 +0000)
Lib/distutils/util.py

index 9de6077fc6daecdd9715abcd9f1fb795243e6143..17fc320aa6c50d75179f01db1ae6280dba576918 100644 (file)
@@ -359,11 +359,18 @@ def byte_compile (py_files,
     # "Indirect" byte-compilation: write a temporary script and then
     # run it with the appropriate flags.
     if not direct:
-        from tempfile import mkstemp
-        (script_fd, script_name) = mkstemp(".py")
+        try:
+            from tempfile import mkstemp
+            (script_fd, script_name) = mkstemp(".py")
+        except ImportError:
+            from tempfile import mktemp
+            (script_fd, script_name) = None, mktemp(".py")
         log.info("writing byte-compilation script '%s'", script_name)
         if not dry_run:
-            script = os.fdopen(script_fd, "w")
+            if script_fd is not None:
+                script = os.fdopen(script_fd, "w")
+            else:
+                script = open(script_name, "w")
 
             script.write("""\
 from distutils.util import byte_compile