Fix Python 3.7 breakage (RH BZ 1577396).

Resolves: rhbz#1577396
This commit is contained in:
Sergio Durigan Junior 2018-06-08 17:04:11 -04:00
parent 732f37d3a4
commit 8014ace474
5 changed files with 78 additions and 1 deletions

View File

@ -512,3 +512,7 @@ Patch122: gdb-rhbz1553104-s390x-arch12-test.patch
# This patch should be removed on the next rebase.
Patch123: gdb-aarch64-guard-sve-macros.patch
# Fix build breakage with Python 3.7
# RHBZ #1577396
Patch124: gdb-fix-python37-breakage.patch

View File

@ -121,3 +121,4 @@
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1

View File

@ -121,3 +121,4 @@ gdb-archer.patch
gdb-vla-intel-fix-print-char-array.patch
gdb-rhbz1553104-s390x-arch12-test.patch
gdb-aarch64-guard-sve-macros.patch
gdb-fix-python37-breakage.patch

View File

@ -0,0 +1,68 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Paul Koning <paul_koning@dell.com>
Date: Fri, 8 Jun 2018 13:26:36 -0400
Subject: gdb-fix-python37-breakage.patch
FileName: gdb-fix-python37-breakage.patch
;; Fix build breakage with Python 3.7
;; RHBZ #1577396
Fix build issue with Python 3.7
Originally reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1577396 -- gdb build fails
with Python 3.7 due to references to a Python internal function whose
declaration changed in 3.7.
gdb/ChangeLog
2018-06-08 Paul Koning <paul_koning@dell.com>
PR gdb/23252
* python/python.c (do_start_initialization):
Avoid call to internal Python API.
(init__gdb_module): New function.
diff --git a/gdb/python/python.c b/gdb/python/python.c
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1810,6 +1810,17 @@ finalize_python (void *ignore)
restore_active_ext_lang (previous_active);
}
+#ifdef IS_PY3K
+/* This is called via the PyImport_AppendInittab mechanism called
+ during initialization, to make the built-in _gdb module known to
+ Python. */
+PyMODINIT_FUNC
+init__gdb_module (void)
+{
+ return PyModule_Create (&python_GdbModuleDef);
+}
+#endif
+
static bool
do_start_initialization ()
{
@@ -1850,6 +1861,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", init__gdb_module);
#else
Py_SetProgramName (progname.release ());
#endif
@@ -1859,9 +1873,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

View File

@ -26,7 +26,7 @@ Version: 8.1.50.%{snapsrc}
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 17%{?dist}
Release: 18%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
Group: Development/Debuggers
@ -1026,6 +1026,9 @@ then
fi
%changelog
* Fri Jun 8 2018 Sergio Durigan Junior <sergiodj@redhat.com> - 8.1.50.20180605-18.fc29
- Fix Python 3.7 breakage (RH BZ 1577396).
* Tue Jun 5 2018 Sergio Durigan Junior <sergiodj@redhat.com> - 8.1.50.20180605-17.fc29
- Rebase to FSF GDB 8.1.50.20180605 (8.2pre).