diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-02-02 19:33:43 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-02-02 19:33:43 (GMT) |
commit | 144fff8b900f9d452402a8e47ff79e88e4916d28 (patch) | |
tree | 0484febfc37dcde4c4bd6c29ab423b439004e3c9 /Lib/venv | |
parent | 7601d780a77ef06541198e434dd83193c6755ee4 (diff) | |
download | cpython-144fff8b900f9d452402a8e47ff79e88e4916d28.zip cpython-144fff8b900f9d452402a8e47ff79e88e4916d28.tar.gz cpython-144fff8b900f9d452402a8e47ff79e88e4916d28.tar.bz2 |
Closes #29213: Merged fix from 3.6.
Diffstat (limited to 'Lib/venv')
-rw-r--r-- | Lib/venv/__init__.py | 10 | ||||
-rw-r--r-- | Lib/venv/scripts/nt/Activate.ps1 | 2 |
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) {
|