From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30011 invoked by alias); 31 May 2018 17:12:21 -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 29990 invoked by uid 89); 31 May 2018 17:12:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: esa3.dell-outbound.iphmx.com Received: from esa3.dell-outbound.iphmx.com (HELO esa3.dell-outbound.iphmx.com) (68.232.153.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 May 2018 17:12:18 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2FfAQCnKxBbh8qZ6ERcHAEBAQQBAQoBA?= =?us-ascii?q?YQYgTUKmFWBWIEwX5JdgXgLhnMhNRcBAgEBAQEBAQIBAQIQAQEBCgsJCCgvgjU?= =?us-ascii?q?igxRRAT5pBBODIoIBqg+IQIFoCQGIN4ITgTMMiByCZIIkAockkUUHAo5hjRIBk?= =?us-ascii?q?RWBQwOCBnBQKgGCGIIgDgmOF2+OSIEZAQE?= X-IPAS-Result: =?us-ascii?q?A2FfAQCnKxBbh8qZ6ERcHAEBAQQBAQoBAYQYgTUKmFWBWIE?= =?us-ascii?q?wX5JdgXgLhnMhNRcBAgEBAQEBAQIBAQIQAQEBCgsJCCgvgjUigxRRAT5pBBODI?= =?us-ascii?q?oIBqg+IQIFoCQGIN4ITgTMMiByCZIIkAockkUUHAo5hjRIBkRWBQwOCBnBQKgG?= =?us-ascii?q?CGIIgDgmOF2+OSIEZAQE?= Received: from esa2.dell-outbound2.iphmx.com ([68.232.153.202]) by esa3.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 12:10:35 -0500 From: Received: from ausxippc101.us.dell.com ([143.166.85.207]) by esa2.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 23:03:01 +0600 X-LoopCount0: from 10.166.136.214 X-DLP: DLP_GlobalPCIDSS To: Subject: [PATCH] fix build failure with Python 3.7 Date: Thu, 31 May 2018 18:20:00 -0000 Message-ID: <96198491-96D8-42F0-9956-1C2BC9277050@dell.com> Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2018-05/txt/msg00865.txt.bz2 This cures PR gdb/33470, build failure due to calling an internal=20 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? paul gdb/ChangeLog: 2018-05-31 Paul Koning PR gdb/33470 * 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); } =20 +#ifdef IS_PY3K +PyMODINIT_FUNC +PyInit__gdb (void) +{ + return PyModule_Create (&python_GdbModuleDef); +} +#endif + 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 (); =20 #ifdef IS_PY3K - gdb_module =3D PyModule_Create (&python_GdbModuleDef); - /* Add _gdb module to the list of known built-in modules. */ - _PyImport_FixupBuiltin (gdb_module, "_gdb"); + gdb_module =3D PyImport_ImportModule ("_gdb"); #else gdb_module =3D Py_InitModule ("_gdb", python_GdbMethods); #endif