Line 0
Link Here
|
|
|
1 |
From aeab512851bf6ed623d1c6c4305b6ce05e51a10c Mon Sep 17 00:00:00 2001 |
2 |
From: Paul Koning <paul_koning@dell.com> |
3 |
Date: Fri, 8 Jun 2018 13:26:36 -0400 |
4 |
Subject: [PATCH] Fix build issue with Python 3.7 |
5 |
|
6 |
Originally reported in |
7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1577396 -- gdb build fails |
8 |
with Python 3.7 due to references to a Python internal function whose |
9 |
declaration changed in 3.7. |
10 |
|
11 |
gdb/ChangeLog |
12 |
2018-06-08 Paul Koning <paul_koning@dell.com> |
13 |
|
14 |
PR gdb/23252 |
15 |
|
16 |
* python/python.c (do_start_initialization): |
17 |
Avoid call to internal Python API. |
18 |
(init__gdb_module): New function. |
19 |
--- |
20 |
gdb/ChangeLog | 8 ++++++++ |
21 |
gdb/python/python.c | 18 +++++++++++++++--- |
22 |
2 files changed, 23 insertions(+), 3 deletions(-) |
23 |
|
24 |
diff --git gdb/ChangeLog gdb/ChangeLog |
25 |
index dbee2a3..12157bb 100644 |
26 |
--- gdb/ChangeLog |
27 |
+++ gdb/ChangeLog |
28 |
@@ -1,3 +1,11 @@ |
29 |
+2018-06-08 Paul Koning <paul_koning@dell.com> |
30 |
+ |
31 |
+ PR gdb/23252 |
32 |
+ |
33 |
+ * python/python.c (do_start_initialization): |
34 |
+ Avoid call to internal Python API. |
35 |
+ (init__gdb_module): New function. |
36 |
+ |
37 |
2018-06-08 Gary Benson <gbenson@redhat.com> |
38 |
|
39 |
* linux-thread-db.c (valprint.h): New include. |
40 |
diff --git gdb/python/python.c gdb/python/python.c |
41 |
index 1805c90..20fc674 100644 |
42 |
--- gdb/python/python.c |
43 |
+++ gdb/python/python.c |
44 |
@@ -1667,6 +1667,17 @@ finalize_python (void *ignore) |
45 |
restore_active_ext_lang (previous_active); |
46 |
} |
47 |
|
48 |
+#ifdef IS_PY3K |
49 |
+/* This is called via the PyImport_AppendInittab mechanism called |
50 |
+ during initialization, to make the built-in _gdb module known to |
51 |
+ Python. */ |
52 |
+PyMODINIT_FUNC |
53 |
+init__gdb_module (void) |
54 |
+{ |
55 |
+ return PyModule_Create (&python_GdbModuleDef); |
56 |
+} |
57 |
+#endif |
58 |
+ |
59 |
static bool |
60 |
do_start_initialization () |
61 |
{ |
62 |
@@ -1707,6 +1718,9 @@ do_start_initialization () |
63 |
remain alive for the duration of the program's execution, so |
64 |
it is not freed after this call. */ |
65 |
Py_SetProgramName (progname_copy); |
66 |
+ |
67 |
+ /* Define _gdb as a built-in module. */ |
68 |
+ PyImport_AppendInittab ("_gdb", init__gdb_module); |
69 |
#else |
70 |
Py_SetProgramName (progname.release ()); |
71 |
#endif |
72 |
@@ -1716,9 +1730,7 @@ do_start_initialization () |
73 |
PyEval_InitThreads (); |
74 |
|
75 |
#ifdef IS_PY3K |
76 |
- gdb_module = PyModule_Create (&python_GdbModuleDef); |
77 |
- /* Add _gdb module to the list of known built-in modules. */ |
78 |
- _PyImport_FixupBuiltin (gdb_module, "_gdb"); |
79 |
+ gdb_module = PyImport_ImportModule ("_gdb"); |
80 |
#else |
81 |
gdb_module = Py_InitModule ("_gdb", python_GdbMethods); |
82 |
#endif |
83 |
-- |
84 |
2.9.3 |
85 |
|