summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-02 19:25:24 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-02 19:25:24 +0000
commitef37141cf58ef24b0096f9ab7fe888b39167f9ec (patch)
tree9cccbb92f5043fbfc9b901fd21458e46040493f3 /Lib
parentdb002681f2e11e960e90a53bd246f7f29cb2583e (diff)
downloadcpython-ef37141cf58ef24b0096f9ab7fe888b39167f9ec.tar.gz
Fixes #29213: regularised EOLs of venv scripts.
Diffstat (limited to 'Lib')
-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 fa0326251e..6bb99cb7be 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -339,19 +339,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 c22b1ea182..85646c89a8 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) {