From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19695 invoked by alias); 23 Nov 2010 17:31:23 -0000 Received: (qmail 19687 invoked by uid 22791); 23 Nov 2010 17:31:21 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Nov 2010 17:31:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 058DE2BAC03; Tue, 23 Nov 2010 12:30:59 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mcD9yW8WG953; Tue, 23 Nov 2010 12:30:58 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CB19D2BABAD; Tue, 23 Nov 2010 12:30:58 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 9BA091457E1; Tue, 23 Nov 2010 09:30:54 -0800 (PST) Date: Tue, 23 Nov 2010 17:31:00 -0000 From: Joel Brobecker To: Doug Evans Cc: Jan Kratochvil , gdb-patches@sourceware.org, David Malcolm Subject: Re: [RFA] ignore PYTHONHOME environment variable. Message-ID: <20101123173054.GW2634@adacore.com> References: <1290474202-885-1-git-send-email-brobecker@adacore.com> <20101123030037.GA19962@host0.dyn.jankratochvil.net> <20101123163045.GA1737@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00361.txt.bz2 > wrote: > > But PYTHONHOME=$HOME for some user overrides of system Python would > > no longer work.  What would $PYTHONHOME otherwise be useful for? > > OTOH what if one wanted to debug a python with a different PYTHONHOME? > GDB_PYTHONHOME? [not my idea, but seems reasonable] I think you indeed need something like that. I don't think we can trust PYTHONHOME, because it might point to something that's incompatible. GDB_PYTHONHOME is something that got suggested by at least 2 people (someone at AdaCore also suggested it a while back). I have to wonder, though, why you would want to run GDB with a different version of Python than then one used to build GDB with. If you want to use your own scripts, you can use the PYTHONPATH. Still, we can add that too, something like that: #ifdef WITH_PYTHON_PATH if "GDB_PYTHONHOME" is defined Py_SetPythonHome (getenv ("GDB_PYTHONHOME")); else /* We override any value that the PYTHONHOME might have, as we want to make sure that we use the Python library that comes with GDB. */ Py_SetPythonHome (ldirname (python_libdir)); #endif But I think I would prefer something like this: if "GDB_PYTHONHOME" is defined Py_SetPythonHome (getenv ("GDB_PYTHONHOME")); #ifdef WITH_PYTHON_PATH else /* We override any value that the PYTHONHOME might have, as we want to make sure that we use the Python library that comes with GDB. */ Py_SetPythonHome (ldirname (python_libdir)); #endif The latter makes GDB_PYTHONHOME always active, regardless of how GDB was linked against Python. -- Joel