Skip to content

Commit 3746619

Browse files
committed
Fixes python#29213: merged fix from 3.5.
2 parents 993f535 + db38b6c commit 3746619

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Lib/venv/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,17 @@ def install_scripts(self, context, path):
320320
dstfile = os.path.join(dstdir, f)
321321
with open(srcfile, 'rb') as f:
322322
data = f.read()
323-
if srcfile.endswith('.exe'):
324-
mode = 'wb'
325-
else:
326-
mode = 'w'
323+
if not srcfile.endswith('.exe'):
327324
try:
328325
data = data.decode('utf-8')
329326
data = self.replace_variables(data, context)
330-
except UnicodeDecodeError as e:
327+
data = data.encode('utf-8')
328+
except UnicodeError as e:
331329
data = None
332330
logger.warning('unable to copy script %r, '
333331
'may be binary: %s', srcfile, e)
334332
if data is not None:
335-
with open(dstfile, mode) as f:
333+
with open(dstfile, 'wb') as f:
336334
f.write(data)
337335
shutil.copymode(srcfile, dstfile)
338336

Lib/venv/scripts/nt/Activate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function global:deactivate ([switch]$NonDestructive) {
2626
}
2727

2828
deactivate -nondestructive
29-
29+
3030
$env:VIRTUAL_ENV="__VENV_DIR__"
3131

3232
if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) {

0 commit comments

Comments
 (0)