diff options
author | dante <dante19031999@gmail.com> | 2021-02-03 12:50:37 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-02-05 11:44:52 +0100 |
commit | 476caeed6e14b3f1cda9435d3fbfa89df0457924 (patch) | |
tree | a507f9c64a6379f7734bad1753f41e6570728be6 /pyuno | |
parent | 7f14ea4431cb4182bccbd9998a60db2f9d9ae07a (diff) |
tdf#138987 Python 3.12 preparations
Change-Id: I8ea476bfbaf27f8ab2daf4a370efc9917a5f9f8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110346
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'pyuno')
-rw-r--r-- | pyuno/source/module/pyuno_type.cxx | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx index 7a919c9bde32..63176c3a2970 100644 --- a/pyuno/source/module/pyuno_type.cxx +++ b/pyuno/source/module/pyuno_type.cxx @@ -138,7 +138,7 @@ sal_Unicode PyChar2Unicode( PyObject *obj ) "uno.Char contains an empty unicode string"); } - sal_Unicode c = static_cast<sal_Unicode>(PyUnicode_AsUnicode( value.get() )[0]); + sal_Unicode c = static_cast<sal_Unicode>(PyUnicode_ReadChar( value.get(), 0)); return c; } @@ -265,11 +265,8 @@ PyObject* PyUNO_char_new ( sal_Unicode val , const Runtime &r ) { // retrieve type object PyRef args( PyTuple_New( 1 ), SAL_NO_ACQUIRE, NOT_NULL ); - - Py_UNICODE u[2]; - u[0] = val; - u[1] = 0; - PyTuple_SetItem( args.get() , 0 , PyUnicode_FromUnicode( u ,1) ); + static_assert(sizeof(sal_Unicode) == sizeof(Py_UCS2), "unexpected size"); + PyTuple_SetItem( args.get() , 0 , PyUnicode_FromKindAndData( PyUnicode_2BYTE_KIND, &val ,1) ); return callCtor( r, "Char" , args ); } |