public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* GDB fails to build with Python 3.7
@ 2018-05-29 13:07 Phil Muldoon
  2018-05-30 23:05 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Muldoon @ 2018-05-29 13:07 UTC (permalink / raw)
  To: gdb@sourceware.org

Currently GDB fails to build with Python 3.7

https://bugs.python.org/issue33470

This is because we use an internal Python API:

#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");
#else
  gdb_module = Py_InitModule ("_gdb", python_GdbMethods);
#endif

(the _PyImport_FixupBuiltin in python.c).

This internal API has been changed. According to the advice of the Python
maintainers we should never have used it in the first place. I didn't
add this (at least I don't think I did!), so I'm asking whomever
authored that code to please change it to be 3.7 compatible. I'm not
sure what the code achieves so I'm reluctant to touch it in case of
breakages on platforms I don't have easily access to.


Cheers

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GDB fails to build with Python 3.7
  2018-05-29 13:07 GDB fails to build with Python 3.7 Phil Muldoon
@ 2018-05-30 23:05 ` Joel Brobecker
  2018-05-31 14:43   ` Paul.Koning
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2018-05-30 23:05 UTC (permalink / raw)
  To: Phil Muldoon, Paul Koning; +Cc: gdb@sourceware.org

Hi Paul,

> Currently GDB fails to build with Python 3.7
> 
> https://bugs.python.org/issue33470
> 
> This is because we use an internal Python API:
> 
> #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");
> #else
>   gdb_module = Py_InitModule ("_gdb", python_GdbMethods);
> #endif
> 
> (the _PyImport_FixupBuiltin in python.c).
> 
> This internal API has been changed. According to the advice of the Python
> maintainers we should never have used it in the first place. I didn't
> add this (at least I don't think I did!), so I'm asking whomever
> authored that code to please change it to be 3.7 compatible. I'm not
> sure what the code achieves so I'm reluctant to touch it in case of
> breakages on platforms I don't have easily access to.

From what I can tell, this was was introduced when you added
Python 3.x support, back in 2012:

    commit 9a27f2c60d760a95a27e336750f26f69f91dd156
    Date:   Wed Dec 12 16:47:30 2012 +0000
    Subject: Add support for Python 3

Do you remember why you added that _PyImport_FixupBuiltin call?

If not, I suggest we just remove it and re-run the testsuite.
If we find regressions, then we'll have our answer. If we don't,
let's just remove the code, and see whether anyone finds something.

-- 
Joel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GDB fails to build with Python 3.7
  2018-05-30 23:05 ` Joel Brobecker
@ 2018-05-31 14:43   ` Paul.Koning
  0 siblings, 0 replies; 3+ messages in thread
From: Paul.Koning @ 2018-05-31 14:43 UTC (permalink / raw)
  To: brobecker; +Cc: pmuldoon, gdb-patches



> On May 30, 2018, at 6:26 PM, Joel Brobecker <brobecker@adacore.com> wrote:
> 
> Hi Paul,
> 
>> Currently GDB fails to build with Python 3.7
>> 
>> https://bugs.python.org/issue33470
>> 
>> This is because we use an internal Python API:
>> 
>> #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");
>> #else
>>  gdb_module = Py_InitModule ("_gdb", python_GdbMethods);
>> #endif
>> 
>> (the _PyImport_FixupBuiltin in python.c).
>> 
>> This internal API has been changed. According to the advice of the Python
>> maintainers we should never have used it in the first place. I didn't
>> add this (at least I don't think I did!), so I'm asking whomever
>> authored that code to please change it to be 3.7 compatible. I'm not
>> sure what the code achieves so I'm reluctant to touch it in case of
>> breakages on platforms I don't have easily access to.
> 
> From what I can tell, this was was introduced when you added
> Python 3.x support, back in 2012:
> 
>    commit 9a27f2c60d760a95a27e336750f26f69f91dd156
>    Date:   Wed Dec 12 16:47:30 2012 +0000
>    Subject: Add support for Python 3
> 
> Do you remember why you added that _PyImport_FixupBuiltin call?
> 
> If not, I suggest we just remove it and re-run the testsuite.
> If we find regressions, then we'll have our answer. If we don't,
> let's just remove the code, and see whether anyone finds something.

I think it was because the PyModule_Create creates a module object, but it doesn't make the module name known so references to it fail.  The FixupBuiltin call makes it a known module.  At least that's what the comment suggests and it tickles a faint memory.

The Python manuals aren't helping me here.  But they suggest something that I missed before, or maybe it wasn't documented at the time.  The API call PyImport_AppendInittab is used to add an entry to a table of compiled-in modules (such as _gdb) that are to be initialized and made known as part of Python initialization.  So it looks like the correct fix is to delete both statements, and instead do a PyImport_AppendInittab before the Py_Initialize call.

I haven't been able to get gdb configure to recognize Python at all on my Mac, unfortunately.

	paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-31 14:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 13:07 GDB fails to build with Python 3.7 Phil Muldoon
2018-05-30 23:05 ` Joel Brobecker
2018-05-31 14:43   ` Paul.Koning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).