Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9713321

Browse files
committed
Document absoluteness of sys.executable
Closes #13402.
1 parent 03c29f9 commit 9713321

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

Doc/library/sys.rst

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

203203
.. data:: executable
204204

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

208210

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

Lib/test/test_sys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@ def test_ioencoding(self):
532532
self.assertEqual(out, b'?')
533533

534534
def test_executable(self):
535+
# sys.executable should be absolute
536+
self.assertEqual(os.path.abspath(sys.executable), sys.executable)
537+
535538
# Issue #7774: Ensure that sys.executable is an empty string if argv[0]
536539
# has been set to an non existent program name and Python is unable to
537540
# retrieve the real program name

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ Extension Modules
454454
Documentation
455455
-------------
456456

457+
- Issue #13402: Document absoluteness of sys.executable.
458+
457459
- Issue #13883: PYTHONCASEOK also used on OS X and OS/2.
458460

459461
- Issue #12949: Document the kwonlyargcount argument for the PyCode_New

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ version_info -- version information as a named tuple\n\
12631263
hexversion -- version information encoded as a single integer\n\
12641264
copyright -- copyright notice pertaining to this interpreter\n\
12651265
platform -- platform identifier\n\
1266-
executable -- pathname of this Python interpreter\n\
1266+
executable -- absolute path of the executable binary of the Python interpreter\n\
12671267
prefix -- prefix used to find the Python library\n\
12681268
exec_prefix -- prefix used to find the machine-specific Python library\n\
12691269
float_repr_style -- string indicating the style of repr() output for floats\n\

0 commit comments

Comments
 (0)