From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27735 invoked by alias); 28 May 2012 14:41:53 -0000 Received: (qmail 27495 invoked by uid 22791); 28 May 2012 14:41:48 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL 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; Mon, 28 May 2012 14:41:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7458F1C697A; Mon, 28 May 2012 10:41:26 -0400 (EDT) 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 N4fjGQNOIWwW; Mon, 28 May 2012 10:41:26 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 099261C6953; Mon, 28 May 2012 10:41:26 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 9C1DE145616; Mon, 28 May 2012 07:41:21 -0700 (PDT) Date: Mon, 28 May 2012 14:41:00 -0000 From: Joel Brobecker To: Jan Kratochvil Cc: Doug Evans , gdb-patches@sourceware.org, David Malcolm , Tom Tromey , Ben Woodard Subject: Re: [RFA] ignore PYTHONHOME environment variable. Message-ID: <20120528144121.GI5492@adacore.com> References: <1290474202-885-1-git-send-email-brobecker@adacore.com> <20101123030037.GA19962@host0.dyn.jankratochvil.net> <20101123163045.GA1737@host0.dyn.jankratochvil.net> <20101123173054.GW2634@adacore.com> <20101214071210.GQ2596@adacore.com> <20101214092645.GA20415@host0.dyn.jankratochvil.net> <20101214103305.GU2596@adacore.com> <20120518193352.GA12340@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120518193352.GA12340@host2.jankratochvil.net> 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: 2012-05/txt/msg00992.txt.bz2 Hi Jan, On Fri, May 18, 2012 at 09:33:52PM +0200, Jan Kratochvil wrote: > 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. Just curious why you revived this discussion. I had written off our changes in this area as vendor-specific, and given up on the idea of putting it in the FSF tree for others to use.... Is there something you need to fix on your side? > 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. This is how we do it at AdaCore: diff --git a/gdb/python/python.c b/gdb/python/python.c index 9a80dea..cc95940 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1222,6 +1222,10 @@ message == an error message without a stack will be printed."), This must be done before calling Py_Initialize. */ Py_SetProgramName (concat (ldirname (python_libdir), SLASH_STRING, "bin", SLASH_STRING, "python", NULL)); + + /* 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 Py_Initialize (); It doesn't look at GDB_PYTHONHOME because we have never encountered a situation when we needed it. But does it answer your question about "ignore it"? We "ignore" the PYTHON_HOME value by just forcing it using Py_SetPythonHome. > Also I believe it should apply to any environment starting with PYTHON* as > besides I less sure about that... The purpose of the proposal to ignore PYTHONHOME is to make sure that the user does not accidently use a Python install which is incompatible with the version that GDB was built with. I am not sure whether we should deal with PYTHONPATH, but it seems that letthing PYTHONVERBOSE through would be OK or even desirable... -- Joel