--- gdb/python/python.c.orig 2017-01-21 22:48:42.000000000 +0900 +++ gdb/python/python.c 2021-12-28 23:59:23.270180000 +0900 @@ -1627,6 +1627,14 @@ /* Provide a prototype to silence -Wmissing-prototypes. */ extern initialize_file_ftype _initialize_python; +#ifdef IS_PY3K +PyMODINIT_FUNC +init__gdb_module (void) +{ + return PyModule_Create (&python_GdbModuleDef); +} +#endif + void _initialize_python (void) { @@ -1743,6 +1751,7 @@ remain alive for the duration of the program's execution, so it is not freed after this call. */ Py_SetProgramName (progname_copy); + PyImport_AppendInittab ("_gdb", init__gdb_module); #else Py_SetProgramName (progname); #endif @@ -1752,9 +1761,7 @@ 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