Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0375079

Browse files
committed
Adding Python <= 2.2 support back in.
1 parent 7f6a439 commit 0375079

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Lib/distutils/util.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,18 @@ def byte_compile (py_files,
359359
# "Indirect" byte-compilation: write a temporary script and then
360360
# run it with the appropriate flags.
361361
if not direct:
362-
from tempfile import mkstemp
363-
(script_fd, script_name) = mkstemp(".py")
362+
try:
363+
from tempfile import mkstemp
364+
(script_fd, script_name) = mkstemp(".py")
365+
except ImportError:
366+
from tempfile import mktemp
367+
(script_fd, script_name) = None, mktemp(".py")
364368
log.info("writing byte-compilation script '%s'", script_name)
365369
if not dry_run:
366-
script = os.fdopen(script_fd, "w")
370+
if script_fd is not None:
371+
script = os.fdopen(script_fd, "w")
372+
else:
373+
script = open(script_name, "w")
367374

368375
script.write("""\
369376
from distutils.util import byte_compile

0 commit comments

Comments
 (0)