STINNER Victor <[email protected]> added the comment:
> 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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35408>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com