Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db38b6c

Browse files
committed
Fixes python#29213: regularised EOLs of venv scripts.
1 parent db6322c commit db38b6c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Lib/venv/__init__.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,17 @@ def install_scripts(self, context, path):
339339
dstfile = os.path.join(dstdir, f)
340340
with open(srcfile, 'rb') as f:
341341
data = f.read()
342-
if srcfile.endswith('.exe'):
343-
mode = 'wb'
344-
else:
345-
mode = 'w'
342+
if not srcfile.endswith('.exe'):
346343
try:
347344
data = data.decode('utf-8')
348345
data = self.replace_variables(data, context)
349-
except UnicodeDecodeError as e:
346+
data = data.encode('utf-8')
347+
except UnicodeError as e:
350348
data = None
351349
logger.warning('unable to copy script %r, '
352350
'may be binary: %s', srcfile, e)
353351
if data is not None:
354-
with open(dstfile, mode) as f:
352+
with open(dstfile, 'wb') as f:
355353
f.write(data)
356354
shutil.copymode(srcfile, dstfile)
357355

Lib/venv/scripts/nt/Activate.ps1

+1-1
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)