summaryrefslogtreecommitdiffstats
path: root/Lib/venv
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2012-10-28 12:40:20 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2012-10-28 12:40:20 (GMT)
commit526417fc59fb846ab5aac9248bc2cbc7b5ed6c45 (patch)
tree013b7dc7cb35b9e462f088c3e5ceb5e306e8c1a7 /Lib/venv
parent42b8932c12f8faaa9462b7cdedb8674d54ddfa1a (diff)
parentbdd13fd09819495ce1bf249a705832ce86968b42 (diff)
downloadcpython-526417fc59fb846ab5aac9248bc2cbc7b5ed6c45.zip
cpython-526417fc59fb846ab5aac9248bc2cbc7b5ed6c45.tar.gz
cpython-526417fc59fb846ab5aac9248bc2cbc7b5ed6c45.tar.bz2
Closes #16340: Merged fix from 3.3.
Diffstat (limited to 'Lib/venv')
-rw-r--r--Lib/venv/__init__.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index e7373e1..1b91c22 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -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):