summaryrefslogtreecommitdiffstats
path: root/Lib/venv
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-02 19:26:48 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-02 19:26:48 (GMT)
commit3746619b84158dfdceaa837fc3e400a98d52fb17 (patch)
tree06eda88a34af535bb53439bf2598eabd1d272997 /Lib/venv
parent993f535ae9276efc7be61fb06a67b629ff92e25d (diff)
parentdb38b6c9a932da89c284cd8377af9f5c4beeb190 (diff)
downloadcpython-3746619b84158dfdceaa837fc3e400a98d52fb17.zip
cpython-3746619b84158dfdceaa837fc3e400a98d52fb17.tar.gz
cpython-3746619b84158dfdceaa837fc3e400a98d52fb17.tar.bz2
Fixes #29213: merged fix from 3.5.
Diffstat (limited to 'Lib/venv')
-rw-r--r--Lib/venv/__init__.py10
-rw-r--r--Lib/venv/scripts/nt/Activate.ps12
2 files changed, 5 insertions, 7 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index 308e046..716129d 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -320,19 +320,17 @@ class EnvBuilder:
dstfile = os.path.join(dstdir, f)
with open(srcfile, 'rb') as f:
data = f.read()
- if srcfile.endswith('.exe'):
- mode = 'wb'
- else:
- mode = 'w'
+ if not srcfile.endswith('.exe'):
try:
data = data.decode('utf-8')
data = self.replace_variables(data, context)
- except UnicodeDecodeError as e:
+ data = data.encode('utf-8')
+ except UnicodeError 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:
+ with open(dstfile, 'wb') as f:
f.write(data)
shutil.copymode(srcfile, dstfile)
diff --git a/Lib/venv/scripts/nt/Activate.ps1 b/Lib/venv/scripts/nt/Activate.ps1
index c22b1ea..85646c8 100644
--- a/Lib/venv/scripts/nt/Activate.ps1
+++ b/Lib/venv/scripts/nt/Activate.ps1
@@ -26,7 +26,7 @@ function global:deactivate ([switch]$NonDestructive) {
}
deactivate -nondestructive
-
+
$env:VIRTUAL_ENV="__VENV_DIR__"
if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) {