summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/util.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-10-07 22:34:13 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-10-07 22:34:13 (GMT)
commit47a4521ecec0cdf9976717bd565c37bee3f566ab (patch)
tree689ca5f85bd7b9f26445f4df202106170fb4b64c /Lib/distutils/util.py
parentdb95c7a60c5ec404523bb7bbc13dd96bf87d15b8 (diff)
downloadcpython-47a4521ecec0cdf9976717bd565c37bee3f566ab.zip
cpython-47a4521ecec0cdf9976717bd565c37bee3f566ab.tar.gz
cpython-47a4521ecec0cdf9976717bd565c37bee3f566ab.tar.bz2
Fix distutils byte-compilation to comply with PEP 3147 (#11254).
Patch by Jeff Ramnani. Tested with -B, -O and -OO.
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r--Lib/distutils/util.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 023ddff..631f5df 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -4,7 +4,11 @@ Miscellaneous utility functions -- anything that doesn't fit into
one of the other *util.py modules.
"""
-import sys, os, string, re
+import os
+import re
+import imp
+import sys
+import string
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
@@ -529,7 +533,10 @@ byte_compile(files, optimize=%r, force=%r,
# Terminology from the py_compile module:
# cfile - byte-compiled file
# dfile - purported source filename (same as 'file' by default)
- cfile = file + (__debug__ and "c" or "o")
+ if optimize >= 0:
+ cfile = imp.cache_from_source(file, debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(file)
dfile = file
if prefix:
if file[:len(prefix)] != prefix: