[Python-checkins] cpython (3.5): Fixes #29213: regularised EOLs of venv scripts.

vinay.sajip python-checkins at python.org
Thu Feb 2 14:27:50 EST 2017


https://hg.python.org/cpython/rev/2b9e5cbdb0b1
changeset: 106392:2b9e5cbdb0b1
branch: 3.5
parent: 106389:1bf1d36463b4
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Thu Feb 02 19:25:24 2017 +0000
summary:
 Fixes #29213: regularised EOLs of venv scripts.
files:
 Lib/venv/__init__.py | 10 ++++------
 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
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -339,19 +339,17 @@
 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
--- a/Lib/venv/scripts/nt/Activate.ps1
+++ b/Lib/venv/scripts/nt/Activate.ps1
@@ -26,7 +26,7 @@
 }
 
 deactivate -nondestructive
-
+
 $env:VIRTUAL_ENV="__VENV_DIR__"
 
 if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) {
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /