I'm seeing deprecation warnings when building against system Python 3.9: /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx: In function ‘sal_Unicode pyuno::PyChar2Unicode(PyObject*)’: /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx:141:79: error: ‘Py_UNICODE* PyUnicode_AsUnicode(PyObject*)’ is deprecated [-Werror=deprecated-declarations] 141 | sal_Unicode c = static_cast<sal_Unicode>(PyUnicode_AsUnicode( value.get() )[0]); | ^ In file included from /usr/include/python3.9/unicodeobject.h:1026, from /usr/include/python3.9/Python.h:97, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_impl.hxx:27, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx:19: /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here 580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( | ^~~~~~~~~~~~~~~~~~~ /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx: In function ‘PyObject* pyuno::PyUNO_char_new(sal_Unicode, const pyuno::Runtime&)’: /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx:272:66: error: ‘PyObject* PyUnicode_FromUnicode(const Py_UNICODE*, Py_ssize_t)’ is deprecated [-Werror=deprecated-declarations] 272 | PyTuple_SetItem( args.get() , 0 , PyUnicode_FromUnicode( u ,1) ); | ^ In file included from /usr/include/python3.9/unicodeobject.h:1026, from /usr/include/python3.9/Python.h:97, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_impl.hxx:27, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx:19: /usr/include/python3.9/cpython/unicodeobject.h:551:42: note: declared here 551 | Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( | ^~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors [build PRL] CustomTarget/postprocess/images/images_karasa_jaga.zip [build PRL] CustomTarget/postprocess/images/images_karasa_jaga_svg.zip [build PRL] CustomTarget/postprocess/images/images_sifr.zip [build PRL] CustomTarget/postprocess/images/images_sifr_dark.zip make[1]: *** [/home/davido/projects/libreoffice/solenv/gbuild/LinkTarget.mk:298: /home/davido/projects/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_type.o] Error 1 make[1]: *** Waiting for unfinished jobs.... /home/davido/projects/libreoffice/pyuno/source/module/pyuno_module.cxx: In function ‘PyObject* PyInit_pyuno()’: /home/davido/projects/libreoffice/pyuno/source/module/pyuno_module.cxx:886:24: error: ‘void PyEval_InitThreads()’ is deprecated [-Werror=deprecated-declarations] 886 | PyEval_InitThreads(); | ^ In file included from /usr/include/python3.9/Python.h:145, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_impl.hxx:27, from /home/davido/projects/libreoffice/pyuno/source/module/pyuno_module.cxx:22: /usr/include/python3.9/ceval.h:130:37: note: declared here 130 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void); | ^~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors /home/davido/projects/libreoffice/pyuno/source/loader/pyuno_loader.cxx: In function ‘void pyuno_loader::{anonymous}::pythonInit()’: /home/davido/projects/libreoffice/pyuno/source/loader/pyuno_loader.cxx:219:24: error: ‘void PyEval_InitThreads()’ is deprecated [-Werror=deprecated-declarations] 219 | PyEval_InitThreads(); | ^ In file included from /usr/include/python3.9/Python.h:145, from /home/davido/projects/libreoffice/pyuno/inc/pyuno.hxx:23, from /home/davido/projects/libreoffice/pyuno/source/loader/pyuno_loader.cxx:23: /usr/include/python3.9/ceval.h:130:37: note: declared here 130 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void); | ^~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[1]: *** [/home/davido/projects/libreoffice/solenv/gbuild/LinkTarget.mk:298: /home/davido/projects/libreoffice/workdir/CxxObject/pyuno/source/loader/pyuno_loader.o] Error 1 make[1]: *** [/home/davido/projects/libreoffice/solenv/gbuild/LinkTarget.mk:298: /home/davido/projects/libreoffice/workdir/CxxObject/pyuno/source/module/pyuno_module.o] Error 1 Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /home/davido/projects/libreoffice/ridljar/com/sun/star/lib/util/WeakMap.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. make: *** [Makefile:283: build] Error 2 [davido@localhost libreoffice]$ /home/davido/projects/libreoffice/pyuno/source/module/pyuno_type.cxx: In function ‘sal_Unicode pyuno::PyChar2Unicode(PyObject*)’: Libreoffice commit: 11382ccf2ff58ba470dfa604654685730e0411f8 gcc --version: gcc (GCC) 11.0.0 20201204
This was discussed on the IRC: <sberg> we have those SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP in sal/types.h that are used in some places to silence such deprecation warnings; maybe you want to add those, for the time being at least? and <mst___> suspect there's no direct replacement for PyUnicode_FromUnicode because PyUnicode_FromKindAndData apparently requires UCS2 not UTF16 <mst___> so in ustring2PyUnicode i guess the solution is to just drop the 2 branches that call it
David Ostrovsky committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6dd1d2268487920e8bda44dfd169a5bda4d62f13 tdf#138987 pyuno: PyEval_InitThreads is a no-op in Python 3.9 It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
David Ostrovsky committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c099288c232c864583b9a263069390a75bf43524 tdf#138987 pyuno: PyEval_InitThreads is a no-op in Python 3.9 It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
there was some more chat last month: <mst___> _david_, ah there is also PyUnicode_FromWideChar - in a different header file <mst___> but it doesn't say if UTF-16 in the wchar_t string is valid <_david_> mst___, so we would have to add some conditions on PY_VERSION_HEX in pyuno on all possible places? <_david_> $ git grep PY_VERSION_HEX | wc -l <_david_> 24 <mst___> _david_ probably the new function can be called if it exists in python 3.3 which is the oldest supprted version on master <mst___> (unless _rene_ raised the requirement?) <_rene_> mst___: didn't, but should be done, probably <_rene_> what I did back then was deprecation stuff inside .py code, not C code anyways <_rene_> but 3.3 is so ancient... <mst___> _david_, oh there is PyUnicode_DecodeUTF16 - probably that's the best option <mst___> there is also PyUnicode_AsUTF16String for the other direction ... but why does it return a PyObject*? <mst___> void PyEval_InitThreads() <mst___> Deprecated function which does nothing. <mst___> _david_, ^ for this one just put in a version check <_david_> mst___, Sure! <mikekaganski> mst___: "but why does it return a PyObject*?" - to maintain Python object refcounting etc? <_rene_> mst___: why not just bump the python version requirement is if it's not bleeding edge? <_rene_> I mean, even Ubutu 16.04(!) has 3.5 <mst___> ah the returned PyObject is a PyBytes, so that should have a way to read the result <mst___> _rene_, sounds good
David Ostrovsky committed a patch related to this issue. It has been pushed to "libreoffice-7-0": https://git.libreoffice.org/core/commit/c82bb0297ea0dbba77823230ed36b81a39e8cbab tdf#138987 pyuno: PyEval_InitThreads is a no-op in Python 3.9 It will be available in 7.0.5. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
David Ostrovsky committed a patch related to this issue. It has been pushed to "libreoffice-7-1": https://git.libreoffice.org/core/commit/d29de0b38ef6854bb129e82fd280f33b0d5b9a08 tdf#138987 pyuno: PyEval_InitThreads is a no-op in Python 3.9 It will be available in 7.1.0.2. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
dante committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/476caeed6e14b3f1cda9435d3fbfa89df0457924 tdf#138987 Python 3.12 preparations It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
A polite ping to DavidO: Is this bug fixed? if so, could you please close it as RESOLVED FIXED ? Otherwise, Could you please explain what's missing? Thanks
Yes, it is fixed.