From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12670 invoked by alias); 23 Nov 2010 01:03:32 -0000 Received: (qmail 12662 invoked by uid 22791); 23 Nov 2010 01:03:31 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD 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 01:03:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5A1832BABC0; Mon, 22 Nov 2010 20:03:26 -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 bqadRF2s254Z; Mon, 22 Nov 2010 20:03:26 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 2A9A22BAB9C; Mon, 22 Nov 2010 20:03:26 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 1C77A1457E1; Mon, 22 Nov 2010 17:03:23 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [RFA] ignore PYTHONHOME environment variable. Date: Tue, 23 Nov 2010 01:03:00 -0000 Message-Id: <1290474202-885-1-git-send-email-brobecker@adacore.com> 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/msg00328.txt.bz2 This is something I hinted during one of our discussion at this year's GCC Summit. If PYTHONHOME is defined in the environment, then Py_SetProgramName does not use the program-name location to find the python library. Instead, it follows the PYTHONHOME, which can cause problems if it points to a different Python installation, particularly if that installation is from a different version of Python. gdb/ChangeLog: * python/python.c (_initialize_python): Call Py_SetPythonHome if GDB was configured with --with-python. Tested on x86_64-linux. Ok to commit? --- gdb/python/python.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index d009be9..4f6f679 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -955,6 +955,12 @@ Enables or disables printing of Python stack traces."), Py_Initialize (); PyEval_InitThreads (); +#ifdef WITH_PYTHON_PATH + /* 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 + gdb_module = Py_InitModule ("gdb", GdbMethods); /* The casts to (char*) are for python 2.4. */ -- 1.7.1