]> granicus.if.org Git - python/commitdiff
Document absoluteness of sys.executable
authorPetri Lehtinen <petri@digip.org>
Thu, 2 Feb 2012 19:11:28 +0000 (21:11 +0200)
committerPetri Lehtinen <petri@digip.org>
Thu, 2 Feb 2012 19:26:05 +0000 (21:26 +0200)
Closes #13402.

Doc/library/sys.rst
Lib/test/test_sys.py
Misc/NEWS
Python/sysmodule.c

index 94947b29904d237a89f17578d1d6d8923aadc335..a52b0d6065355ce33ef5dddde632979ba4cf7992 100644 (file)
@@ -215,8 +215,10 @@ always available.
 
 .. data:: executable
 
-   A string giving the name of the executable binary for the Python interpreter, on
-   systems where this makes sense.
+   A string giving the absolute path of the executable binary for the Python
+   interpreter, on systems where this makes sense. If Python is unable to retrieve
+   the real path to its executable, :data:`sys.executable` will be an empty string
+   or ``None``.
 
 
 .. function:: exit([arg])
index 6c5fc2408f6503190ca823820c1407952d5c5380..6e37ac4487e2ef89e688ec24b71b5d6b2db10b08 100644 (file)
@@ -471,6 +471,9 @@ class SysModuleTest(unittest.TestCase):
         self.assertRaises(TypeError, sys.call_tracing, str, 2)
 
     def test_executable(self):
+        # sys.executable should be absolute
+        self.assertEqual(os.path.abspath(sys.executable), sys.executable)
+
         # 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
index 55f2506a4696808daef1cb16e4f9ccff1c274d37..d7eb5d92ff06d0078e68af34c1a4404e01230201 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -509,6 +509,8 @@ Tests
 Documentation
 -------------
 
+- Issue #13402: Document absoluteness of sys.executable.
+
 - Issue #13883: PYTHONCASEOK also works on OS X, OS/2, and RiscOS.
 
 - Issue #2134: The tokenize documentation has been clarified to explain why
index 692805bff3c3911631772ddf428f0ccf94cfe096..a0374fb71b61a7c4bf288179d36a3f216a4ac349 100644 (file)
@@ -1093,7 +1093,7 @@ version_info -- version information as a named tuple\n\
 hexversion -- version information encoded as a single integer\n\
 copyright -- copyright notice pertaining to this interpreter\n\
 platform -- platform identifier\n\
-executable -- pathname of this Python interpreter\n\
+executable -- absolute path of the executable binary of the Python interpreter\n\
 prefix -- prefix used to find the Python library\n\
 exec_prefix -- prefix used to find the machine-specific Python library\n\
 float_repr_style -- string indicating the style of repr() output for floats\n\