From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84965 invoked by alias); 31 May 2018 20:10:49 -0000 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 Received: (qmail 73234 invoked by uid 89); 31 May 2018 20:10:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=correspondent X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 May 2018 20:10:34 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CFF44026632; Thu, 31 May 2018 20:10:33 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DC0F208C19A; Thu, 31 May 2018 20:10:33 +0000 (UTC) From: Sergio Durigan Junior To: Cc: Subject: Re: [PATCH] fix build failure with Python 3.7 References: <96198491-96D8-42F0-9956-1C2BC9277050@dell.com> Date: Thu, 31 May 2018 20:45:00 -0000 In-Reply-To: <96198491-96D8-42F0-9956-1C2BC9277050@dell.com> (Paul Koning's message of "Thu, 31 May 2018 17:12:14 +0000") Message-ID: <87fu27fux2.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00871.txt.bz2 On Thursday, May 31 2018, Paul Koning wrote: > This cures PR gdb/33470, build failure due to calling an internal > API in Python that changed in V3.7. The code now uses the > "inittab" mechanism in Python, which is the approved way to > make compiled-in modules known to Python. > > Gdb starts properly and I can see the _gdb module. On my test > system (a Mac) it's hard to get gdb to run at all, so the > test suite is a bit problematic. What other tests are needed? Thanks for the patch, Paul. I'll run this on BuildBot and see what comes out of it. Meanwhile... > paul > > gdb/ChangeLog: > > 2018-05-31 Paul Koning > > PR gdb/33470 This bug number is actually from Python's bugzilla, not GDB's. So it's not correct to mention it here in the ChangeLog/commit message. AFAIK, there's no correspondent GDB bug filed for this issue. > * python/python.c (do_start_initialization): > Avoid call to internal Python API. > (PyInit__gdb): New function. > > diff --git a/gdb/python/python.c b/gdb/python/python.c > index c29e7d7a6b..89443aee25 100644 > --- a/gdb/python/python.c > +++ b/gdb/python/python.c > @@ -1667,6 +1667,14 @@ finalize_python (void *ignore) > restore_active_ext_lang (previous_active); > } > > +#ifdef IS_PY3K > +PyMODINIT_FUNC > +PyInit__gdb (void) > +{ > + return PyModule_Create (&python_GdbModuleDef); > +} > +#endif I think it's a good idea to add a comment to this function. > + > static bool > do_start_initialization () > { > @@ -1707,6 +1715,9 @@ do_start_initialization () > remain alive for the duration of the program's execution, so > it is not freed after this call. */ > Py_SetProgramName (progname_copy); > + > + /* Define _gdb as a built-in module. */ > + PyImport_AppendInittab ("_gdb", PyInit__gdb); > #else > Py_SetProgramName (progname.release ()); > #endif > @@ -1716,9 +1727,7 @@ do_start_initialization () > PyEval_InitThreads (); > > #ifdef IS_PY3K > - gdb_module = PyModule_Create (&python_GdbModuleDef); > - /* Add _gdb module to the list of known built-in modules. */ > - _PyImport_FixupBuiltin (gdb_module, "_gdb"); > + gdb_module = PyImport_ImportModule ("_gdb"); > #else > gdb_module = Py_InitModule ("_gdb", python_GdbMethods); > #endif -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/