This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] ignore PYTHONHOME environment variable.
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: Doug Evans <dje at google dot com>, gdb-patches at sourceware dot org, David Malcolm <dmalcolm at redhat dot com>, Tom Tromey <tromey at redhat dot com>, Ben Woodard <woodard at redhat dot com>
- Date: Fri, 18 May 2012 21:33:52 +0200
- Subject: Re: [RFA] ignore PYTHONHOME environment variable.
- References: <1290474202-885-1-git-send-email-brobecker@adacore.com> <20101123030037.GA19962@host0.dyn.jankratochvil.net> <AANLkTiko2FVL+ktF9JTBRedYz_wvsq_eP4rU3rLcOYmF@mail.gmail.com> <20101123163045.GA1737@host0.dyn.jankratochvil.net> <AANLkTi=W+PnwOfNkRRe5OMz0qm5vCghhduO5ve1Qk3zH@mail.gmail.com> <20101123173054.GW2634@adacore.com> <20101214071210.GQ2596@adacore.com> <20101214092645.GA20415@host0.dyn.jankratochvil.net> <20101214103305.GU2596@adacore.com>
On Tue, 14 Dec 2010 11:33:05 +0100, Joel Brobecker wrote:
> What we can also do is warn users when we see that PYTHONHOME is
> defined and not GDB_PYTHON_HOME. That way, they are not surprised
> when that happens, and they get a helpful indication of how to
> remedy the problem.
Therefore:
if ($GDB_PYTHONHOME exists) {
use it
} else if ($PYTHONHOME exists) {
warn on it
ignore it
pass it to spawned debuggees
} else {
let Python use it's defaults
}
That "ignore it" part may be difficult as despite Py_SetPythonHome overrides
$PYTHONHOME if !defined WITH_PYTHON_PATH we do not know which string to use
for Py_SetPythonHome to override it. So maybe to use unsetenv before
Py_Initialize and setenv the saved string back afterwards.
Also I believe it should apply to any environment starting with PYTHON* as
besides
$ PYTHONHOME=/foo ./gdb
ImportError: No module named site
it affects also at least
$ echo foo >site.py; PYTHONPATH=. ./gdb
Traceback (most recent call last):
File "./site.py", line 1, in <module>
foo
NameError: name 'foo' is not defined
and
$ PYTHONVERBOSE=1 ./gdb
# installing zipimport hook
import zipimport # builtin
[...]
import gdb.command.upto # precompiled from /usr/share/gdb/python/gdb/command/upto.pyc
GNU gdb (GDB) 7.4.50.20120512-cvs
[...]
Thanks,
Jan