[PATCH] Fix compilation of python/python.c for Python 3.9

Kevin Buettner kevinb@redhat.com
Wed Apr 15 18:14:53 GMT 2020


On Wed, 15 Apr 2020 14:02:32 -0400
Paul Koning <paulkoning@comcast.net> wrote:

> > On Apr 15, 2020, at 1:54 PM, Kevin Buettner via Gdb-patches <gdb-patches@sourceware.org> wrote:
> > 
> > This commit fixes a compilation warning/error when building GDB
> > with Python 3.9:
> > 
> > ...
> > 
> > Specifically, with regard to PyEval_InitThreads(), it says:
> > 
> >    The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions
> >    are now deprecated and will be removed in Python 3.11.  Calling
> >    PyEval_InitThreads() now does nothing.  The GIL is initialized by
> >    Py_Initialize() since Python 3.7.  (Contributed by Victor Stinner
> >    in bpo-39877.)
> > 
> > I chose to disable the call with a #if test using PY_VERSION_HEX.  
> 
> > ...
> >   Py_Initialize ();
> > +#if PY_VERSION_HEX < 0x03090000
> > +  /* PyEval_InitThreads became deprecated in Python 3.9 and will
> > +     be removed in Python 3.11.  Prior to Python 3.7, this call was
> > +     required to initialize the GIL.  */
> >   PyEval_InitThreads ();
> > +#endif  
> 
> Since it is not needed as of 3.7, would it make sense for the #if to be on 0x03070000 instead?

It does make sense, and I'm willing to change it if that's the
consensus.  I simply chose to use the version number where the call in
question became deprecated.

Kevin



More information about the Gdb-patches mailing list