diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 20020be..8030804 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -202,8 +202,9 @@ 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. .. function:: exit([arg]) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index f89514f..7a94bb7 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -542,6 +542,9 @@ class SysModuleTest(unittest.TestCase): self.assertEqual(out, b'?') 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 diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ab0008e..ba93602 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1257,7 +1257,7 @@ Static objects:\n\ builtin_module_names -- tuple of module names built into this interpreter\n\ copyright -- copyright notice pertaining to this interpreter\n\ exec_prefix -- prefix used to find the machine-specific Python library\n\ -executable -- pathname of this Python interpreter\n\ +executable -- absolute path of the executable binary of this Python interpreter\n\ float_info -- a struct sequence with information about the float implementation.\n\ float_repr_style -- string indicating the style of repr() output for floats\n\ hexversion -- version information encoded as a single integer\n\