fonttools / openstep-plist

OpenStep plist parser and writer written in Cython
MIT License
7 stars 3 forks source link

PyUnicode deprecated functions #18

Closed simoncozens closed 1 year ago

simoncozens commented 1 year ago

These appear to be deprecated in 3.11:

src/openstep_plist/writer.cpp:4530:15: warning: 'PyUnicode_FromUnicode' is deprecated [-Wdeprecated-declarations]
  __pyx_t_1 = PyUnicode_FromUnicode(((Py_UNICODE const *)__pyx_v_self->dest->data()), __pyx_v_self->dest->size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)

src/openstep_plist/writer.cpp:5937:15: warning: 'PyUnicode_AS_UNICODE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_s = PyUnicode_AS_UNICODE(__pyx_v_string);

src/openstep_plist/writer.cpp:5946:20: warning: 'PyUnicode_GET_SIZE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_length = PyUnicode_GET_SIZE(__pyx_v_string);

src/openstep_plist/writer.cpp:6008:15: warning: 'PyUnicode_AS_UNICODE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_s = PyUnicode_AS_UNICODE(__pyx_v_string);

src/openstep_plist/writer.cpp:6017:20: warning: 'PyUnicode_GET_SIZE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_length = PyUnicode_GET_SIZE(__pyx_v_string);

src/openstep_plist/writer.cpp:6150:15: warning: 'PyUnicode_AS_UNICODE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_s = PyUnicode_AS_UNICODE(__pyx_v_string);

src/openstep_plist/writer.cpp:6159:20: warning: 'PyUnicode_GET_SIZE' is deprecated [-Wdeprecated-declarations]
  __pyx_v_length = PyUnicode_GET_SIZE(__pyx_v_string);
simoncozens commented 1 year ago

Indeed I wonder if the changes to Py_UNICODE are why I'm getting this build error:

/Users/simon/others-repos/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__iterator/back_insert_iterator.h:35:15: error: 'container' declared as a pointer to a reference of type 'std::vector<wchar_t> &'
    _Container* container;
              ^
src/openstep_plist/writer.cpp:4464:131: note: in instantiation of template class 'std::back_insert_iterator<std::vector<wchar_t> &>' requested here
    std::copy<Py_UNICODE const *,std::back_insert_iterator<std::vector<Py_UNICODE>  &> >(__pyx_v_s, (__pyx_v_s + __pyx_v_length), std::back_inserter<std::vector<Py_UNICODE>  &>((__pyx_v_self->dest[0])));
IvanUkhov commented 1 year ago

Oh, just saw your message, which is relevant to #19 and #20. Good that I am not the only one 😀

anthrotype commented 1 year ago

looks like we need to get rid of the deprecated Py_UNICODE apis to make openstep-plist PEP 393 compliant and being able to build 3.12 wheels:

https://docs.python.org/3/c-api/unicode.html#deprecated-py-unicode-apis https://peps.python.org/pep-0393/

I suppose we can get away with using wchar_t instead of Py_UNICODE, with the related conversion functions to/from PyUnicode