This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Volker Weißmann
Recipients Volker Weißmann
Date 2020-04-07.20:16:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1586290599.79.0.960995339825.issue40218@roundup.psfhosted.org>
In-reply-to
Content
Note: I'm not sure if this is a bug in python or in gdb. I will also submit a bug report to gdb and post a link here.

Pythons documentation says that sys.executable is always either None, empty string or a path to the python interpreter. Using gdb and python, we can produce situations where this is not true.

Simple but unrealistic way to reproduce this bug:
Install gdb with python support. E.g using
$ pacman -S gdb
Remove all the python binaries:
$ rm /usr/bin/python
$ rm /usr/bin/python3
$ rm /usr/bin/python3.8
Run $gdb -x gdbinit$ with the contents of gdbinit being:
python
import sys
import os
print(sys.executable)
print(os.path.exists(sys.executable))
end

Result:
/usr/bin/python
False

Here, sys.executable is /usr/bin/python, but there is no python executable in /usr/bin/python, because we just deleted it.

Complicated but realistic way to reproduce this bug:
Build gdb with
../configure --with-python=python2
and run gdb with the gdbinit being:
python
import sys
print(sys.executable)
print(sys.version)
end
Result:
/usr/bin/python
2.7.17 (default, Mar 21 2020, 00:47:07) 
[GCC 9.3.0]
Here it says that the python2 executable lies in "/usr/bin/python", even if there is no python2 executable in /usr/bin/python.
History
Date User Action Args
2020-04-07 20:16:39Volker Weißmannsetrecipients: + Volker Weißmann
2020-04-07 20:16:39Volker Weißmannsetmessageid: <1586290599.79.0.960995339825.issue40218@roundup.psfhosted.org>
2020-04-07 20:16:39Volker Weißmannlinkissue40218 messages
2020-04-07 20:16:39Volker Weißmanncreate