X Tutup
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit fe6f9d0

Browse files
committed
Document absoluteness of sys.executable
Closes python#13402.
1 parent da6db4f commit fe6f9d0

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Doc/library/sys.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ always available.
215215

216216
.. data:: executable
217217

218-
A string giving the name of the executable binary for the Python interpreter, on
219-
systems where this makes sense.
218+
A string giving the absolute path of the executable binary for the Python
219+
interpreter, on systems where this makes sense. If Python is unable to retrieve
220+
the real path to its executable, :data:`sys.executable` will be an empty string
221+
or ``None``.
220222

221223

222224
.. function:: exit([arg])

Lib/test/test_sys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ def test_call_tracing(self):
471471
self.assertRaises(TypeError, sys.call_tracing, str, 2)
472472

473473
def test_executable(self):
474+
# sys.executable should be absolute
475+
self.assertEqual(os.path.abspath(sys.executable), sys.executable)
476+
474477
# Issue #7774: Ensure that sys.executable is an empty string if argv[0]
475478
# has been set to an non existent program name and Python is unable to
476479
# retrieve the real program name

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ Tests
509509
Documentation
510510
-------------
511511

512+
- Issue #13402: Document absoluteness of sys.executable.
513+
512514
- Issue #13883: PYTHONCASEOK also works on OS X, OS/2, and RiscOS.
513515

514516
- Issue #2134: The tokenize documentation has been clarified to explain why

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ version_info -- version information as a named tuple\n\
10931093
hexversion -- version information encoded as a single integer\n\
10941094
copyright -- copyright notice pertaining to this interpreter\n\
10951095
platform -- platform identifier\n\
1096-
executable -- pathname of this Python interpreter\n\
1096+
executable -- absolute path of the executable binary of the Python interpreter\n\
10971097
prefix -- prefix used to find the Python library\n\
10981098
exec_prefix -- prefix used to find the machine-specific Python library\n\
10991099
float_repr_style -- string indicating the style of repr() output for floats\n\

0 commit comments

Comments
 (0)
X Tutup