[Python-checkins] cpython (3.2): Document absoluteness of sys.executable
petri.lehtinen
python-checkins at python.org
Thu Feb 2 20:30:21 CET 2012
http://hg.python.org/cpython/rev/fdcda5b74317
changeset: 74725:fdcda5b74317
branch: 3.2
parent: 74722:a55ffb6c1993
user: Petri Lehtinen <petri at digip.org>
date: Thu Feb 02 20:59:48 2012 +0200
summary:
Document absoluteness of sys.executable
Closes #13402.
files:
Doc/library/sys.rst | 6 ++++--
Lib/test/test_sys.py | 3 +++
Misc/NEWS | 2 ++
Python/sysmodule.c | 2 +-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -202,8 +202,10 @@
.. 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])
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -532,6 +532,9 @@
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/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -454,6 +454,8 @@
Documentation
-------------
+- Issue #13402: Document absoluteness of sys.executable.
+
- Issue #13883: PYTHONCASEOK also used on OS X and OS/2.
- Issue #12949: Document the kwonlyargcount argument for the PyCode_New
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1263,7 +1263,7 @@
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\
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list