mcfletch / simpleparse

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

Fix for a missing macro in python 3.11 #18

Open chrisBrookes93 opened 2 years ago

chrisBrookes93 commented 2 years ago

There are still lots of deprecation warning when building (as there was in the previous release), but this fixes compilation errors when trying to build/install in python 3.11:

Fixes for the errors: simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2901:6: error: implicit declaration of function 'Py_UNICODE_COPY' is invalid in C99 [-Werror,-Wimplicit-function-declaration] Py_UNICODE_COPY(p, sep, sep_len); ^ simpleparse/stt/TextTools/mxTextTools/mxTextTools.c:2907:2: error: implicit declaration of function 'Py_UNICODE_COPY' is invalid in C99 [-Werror,-Wimplicit-function-declaration] Py_UNICODE_COPY(p, st, len_st);

Following suggested guidance here: https://docs.python.org/3.11/whatsnew/3.11.html#:~:text=Remove%20Py_UNICODE_COPY()%20and%20Py_UNICODE_FILL()%20macros%2C%20deprecated%20since%20Python%203.3.%20Use%20PyUnicode_CopyCharacters()%20or%20memcpy()%20(wchar_t*%20string)%2C%20and%20PyUnicode_Fill()%20functions%20instead.%20(Contributed%20by%20Victor%20Stinner%20in%20bpo%2D41123.)

The previous implemented (Py_UNICODE_COPY, here: https://github.com/python/cpython/pull/28887/files#diff-6be7f081fe6c5e9cbc89323a00399b291d1cda855bcb4c6eeaee0fac89c2f8ddL54) is using a mem copy which assumes 0 indexes for the source and target array. Uplifted code to use the new suggested function with explicit 0 indexes

chrisBrookes93 commented 2 years ago

There isn't an appveyor image with python3.11 right now: https://www.appveyor.com/docs/windows-images-software/#python

But the tests do pass locally:

image

chrisBrookes93 commented 1 year ago

@mcfletch Would you mind taking a look at this when you get a second please? :)

chrisBrookes93 commented 1 year ago

@mcfletch any chance of moving this forward?