mcfletch / simpleparse

SimpleParse parser generator using mxTextTools (launchpad mirror)
Other
10 stars 12 forks source link

simpleparse fails to compile with Python3.9 #10

Closed maurizio-lombardi closed 2 years ago

maurizio-lombardi commented 4 years ago

Hello,

Fedora is introducing Python 3.9 and simpleparse doesn't successfully compile anymore. Apparently, the problem is due to the fact that simpleparse still uses the old, deprecated buffer protocol (it depends on PyObject_AsCharBuffer)

https://docs.python.org/3/c-api/objbuffer.html

/mxTextTools.c:389:6: warning: ‘PyObject_AsCharBuffer’ is deprecated [-Wdeprecated-declarations] 389 | else if (PyObject_AsCharBuffer(so->match, &match, &match_len)) | ^~~~ In file included from /usr/include/python3.9/Python.h:151, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mx.h:60, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:18: /usr/include/python3.9/abstract.h:326:17: note: declared here 326 | PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, | ^~~~~ In file included from /usr/include/python3.9/pytime.h:6, from /usr/include/python3.9/Python.h:85, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mx.h:60, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:18: /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c: In function ‘mxTextTools_UnicodeJoin’: /usr/include/python3.9/object.h:625:41: error: expected ‘(’ before ‘PyType_HasFeature’ 625 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) | ^~~~~ /usr/include/python3.9/tupleobject.h:27:18: note: in expansion of macro ‘PyType_FastSubclass’ 27 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) | ^~~~~~~ /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2838:5: note: in expansion of macro ‘PyTuple_Check’ 2838 | if PyTuple_Check(o) { | ^~~~~ /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2838:22: error: expected ‘;’ before ‘{’ token 2838 | if PyTuple_Check(o) { | ^ In file included from /usr/include/python3.9/pytime.h:6, from /usr/include/python3.9/Python.h:85, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mx.h:60, from /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:18: /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c: In function ‘mxTextTools_Join’: /usr/include/python3.9/object.h:625:41: error: expected ‘(’ before ‘PyType_HasFeature’ 625 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) | ^~~~~ /usr/include/python3.9/tupleobject.h:27:18: note: in expansion of macro ‘PyType_FastSubclass’ 27 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) | ^~~~~~~ /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2983:5: note: in expansion of macro ‘PyTuple_Check’ 2983 | if PyTuple_Check(o) { | ^~~~~ /builddir/build/BUILD/SimpleParse-2.2.0/simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2983:22: error: expected ‘;’ before ‘{’ token 2983 | if PyTuple_Check(o) { | ^ error: command '/usr/bin/gcc' failed with exit code 1

yoursvivek commented 2 years ago

@mcfletch Can you publish master on pypi? WIthout the fix from #11 pypi package doesn't install on python3.9.

aliaksei-chareshneu commented 2 years ago

@mcfletch, is simpleparse supported on Python 3.9?

maurizio-lombardi commented 2 years ago

I'm closing this issue because the necessary patch has been merged: https://github.com/mcfletch/simpleparse/pull/11

aliaksei-chareshneu commented 2 years ago

@maurizio-lombardi, could you update it on pypi too? I think now it works only while installing from github (though I may be wrong).