[Python-checkins] cpython (merge 3.4 -> default): Closes #21643: Merged fix from 3.4.

vinay.sajip python-checkins at python.org
Tue Jun 3 17:49:27 CEST 2014


http://hg.python.org/cpython/rev/71eda9bd8875
changeset:   90998:71eda9bd8875
parent:      90996:99b469758f49
parent:      90997:27e1b4a9de07
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Tue Jun 03 16:48:39 2014 +0100
summary:
  Closes #21643: Merged fix from 3.4.

files:
  Lib/test/test_venv.py |  27 ++++++++++++++++-----------
  Lib/venv/__init__.py  |   6 +++---
  2 files changed, 19 insertions(+), 14 deletions(-)


diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -203,17 +203,22 @@
         """
         Test upgrading an existing environment directory.
         """
-        builder = venv.EnvBuilder(upgrade=True)
-        self.run_with_capture(builder.create, self.env_dir)
-        self.isdir(self.bindir)
-        self.isdir(self.include)
-        self.isdir(*self.lib)
-        fn = self.get_env_file(self.bindir, self.exe)
-        if not os.path.exists(fn):  # diagnostics for Windows buildbot failures
-            bd = self.get_env_file(self.bindir)
-            print('Contents of %r:' % bd)
-            print('    %r' % os.listdir(bd))
-        self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn)
+        # See Issue #21643: the loop needs to run twice to ensure
+        # that everything works on the upgrade (the first run just creates
+        # the venv).
+        for upgrade in (False, True):
+            builder = venv.EnvBuilder(upgrade=upgrade)
+            self.run_with_capture(builder.create, self.env_dir)
+            self.isdir(self.bindir)
+            self.isdir(self.include)
+            self.isdir(*self.lib)
+            fn = self.get_env_file(self.bindir, self.exe)
+            if not os.path.exists(fn):
+                # diagnostics for Windows buildbot failures
+                bd = self.get_env_file(self.bindir)
+                print('Contents of %r:' % bd)
+                print('    %r' % os.listdir(bd))
+            self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn)
 
     def test_isolation(self):
         """
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -30,7 +30,6 @@
 import logging
 import os
 import shutil
-import struct
 import subprocess
 import sys
 import types
@@ -140,11 +139,12 @@
         create_if_needed(path)
         create_if_needed(libpath)
         # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
-        if ((struct.calcsize('P') == 8) and (os.name == 'posix') and
+        if ((sys.maxsize > 2**32) and (os.name == 'posix') and
             (sys.platform != 'darwin')):
             p = os.path.join(env_dir, 'lib')
             link_path = os.path.join(env_dir, 'lib64')
-            os.symlink(p, link_path)
+            if not os.path.exists(link_path):   # Issue #21643
+                os.symlink(p, link_path)
         context.bin_path = binpath = os.path.join(env_dir, binname)
         context.bin_name = binname
         context.env_exe = os.path.join(binpath, exename)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list