This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients etejedor, vstinner
Date 2018-12-04.14:24:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543933496.38.0.788709270274.issue35408@psf.upfronthosting.co.za>
In-reply-to
Content
> Python3.7 crash in PyCFunction_New due to broken _PyObject_GC_TRACK

It's unrelated. Your must not use the Python API before Python is initialized. If you modify your code like that, it works as expected:

int main()
{
Py_Initialize();

  PyMethodDef methoddef_ = {
    const_cast< char* >( "myfun" ),
    (PyCFunction) myfun,
    METH_O,
    NULL
  };

  PyObject* myFunPtr = PyCFunction_New( &methoddef_, NULL );

Py_Finalize();
  return 0;
}

I don't think that it's a regression.

Python initialization is now well documented:
https://docs.python.org/dev/c-api/init.html

The documentation starts with:

"In an application embedding Python, the Py_Initialize() function must be called before using any other Python/C API functions; with the exception of a few functions and the global configuration variables."

PyCFunction_New() is an example of function of the Python C API.
History
Date User Action Args
2018-12-04 14:24:56vstinnersetrecipients: + vstinner, etejedor
2018-12-04 14:24:56vstinnersetmessageid: <1543933496.38.0.788709270274.issue35408@psf.upfronthosting.co.za>
2018-12-04 14:24:56vstinnerlinkissue35408 messages
2018-12-04 14:24:56vstinnercreate