diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-11 12:34:39 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-11 12:34:39 +0000 |
commit | 4a7e0c858c624eee49b9b1a977c887f5b49d0fd4 (patch) | |
tree | 7d40b555b47d3d472e6192803f8aaa051bae31cc /Lib/test/test_sys.py | |
parent | 637637021a52d083f47dfdd6dd0cc16e31696409 (diff) | |
download | cpython-git-4a7e0c858c624eee49b9b1a977c887f5b49d0fd4.tar.gz |
Issue #7774: Set sys.executable to an empty string if argv[0] has been
set to an non existent program name and Python is unable to retrieve the real
program name.
Fix also sysconfig: if sys.executable is an empty string, use the current
working directory.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r-- | Lib/test/test_sys.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 15b88ceb39..e41814bfd6 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -437,6 +437,17 @@ class SysModuleTest(unittest.TestCase): self.assertEqual(sys.call_tracing(str, (2,)), "2") self.assertRaises(TypeError, sys.call_tracing, str, 2) + def test_executable(self): + # Issue #7774: Ensure that sys.executable is an empty string if argv[0] + # has been set to an non existent program name and Python is unable to + # retrieve the real program name + import subprocess + p = subprocess.Popen( + ["nonexistent", "-c", 'import sys; print "executable=%r" % sys.executable'], + executable=sys.executable, stdout=subprocess.PIPE) + executable = p.communicate()[0].strip() + p.wait() + self.assertEqual(executable, "executable=''") class SizeofTest(unittest.TestCase): |