]> granicus.if.org Git - python/commitdiff
Fix the test_subprocess failure when sys.executable is meaningless: '' or a directory.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 11 Mar 2010 00:56:59 +0000 (00:56 +0000)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 11 Mar 2010 00:56:59 +0000 (00:56 +0000)
It does not fix #7774.

Lib/sysconfig.py
Lib/test/test_subprocess.py

index 69264d2e4811cce71a0cf2a513307f6db4ea7ecd..2b14bfe032d67d220f27bf5f1f5304da80dfaeaa 100644 (file)
@@ -84,7 +84,8 @@ _PREFIX = os.path.normpath(sys.prefix)
 _EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
 _CONFIG_VARS = None
 _USER_BASE = None
-_PROJECT_BASE = os.path.dirname(realpath(sys.executable))
+# Note: sys.executable can be '' or even a directory, until #7774 is fixed.
+_PROJECT_BASE = realpath(os.path.dirname(sys.executable))
 
 if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
     _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir))
@@ -294,7 +295,7 @@ def _init_non_posix(vars):
     vars['SO'] = '.pyd'
     vars['EXE'] = '.exe'
     vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
-    vars['BINDIR'] = os.path.dirname(realpath(sys.executable))
+    vars['BINDIR'] = realpath(os.path.dirname(sys.executable))
 
 #
 # public APIs
index dc57c46b4569ca7325d305a77c0017f89783fc91..365ac91279a87377cb995484c94837e45640754d 100644 (file)
@@ -135,7 +135,7 @@ class ProcessTestCase(unittest.TestCase):
         self.assertEqual(p.stderr, None)
 
     def test_executable_with_cwd(self):
-        python_dir = os.path.dirname(os.path.realpath(sys.executable))
+        python_dir = os.path.realpath(os.path.dirname(sys.executable))
         p = subprocess.Popen(["somethingyoudonthave", "-c",
                               "import sys; sys.exit(47)"],
                              executable=sys.executable, cwd=python_dir)