Closes #16340: Merged fix from 3.3.

This commit is contained in:
Vinay Sajip 2012-10-28 12:40:20 +00:00
commit 526417fc59
1 changed files with 11 additions and 5 deletions

View File

@ -313,11 +313,17 @@ class EnvBuilder:
mode = 'wb'
else:
mode = 'w'
data = data.decode('utf-8')
data = self.replace_variables(data, context)
with open(dstfile, mode) as f:
f.write(data)
shutil.copymode(srcfile, dstfile)
try:
data = data.decode('utf-8')
data = self.replace_variables(data, context)
except UnicodeDecodeError as e:
data = None
logger.warning('unable to copy script %r, '
'may be binary: %s', srcfile, e)
if data is not None:
with open(dstfile, mode) as f:
f.write(data)
shutil.copymode(srcfile, dstfile)
def create(env_dir, system_site_packages=False, clear=False, symlinks=False):