Don't use OUStringBuffer::apendAscii with UTF-8

(Stumbled over this when while preparing
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest" I accidentally forgot the

> from org.libreoffice.embindtest import Exception

in pyuno/qa/pytests/embindtest.py and thus PythonTest_pyuno_pytests_embindtest
would SIGABRT with

> sal/rtl/strtmpl.hxx:122: auto rtl::str::Copy(sal_Unicode *, const char *, sal_Int32)::(anonymous class)::operator()(char) const: Assertion `rtl::isAscii(static_cast<unsigned char>(c))' failed.

from pyuno::lcl_ExceptionMessage (with reprString being "('error', None,
-123456, 100.5, 'hä')") while trying to report

> uno.com.sun.star.uno.RuntimeException: Couldn't convert ('error', None, -123456, 100.5, 'hä') to a UNO type; caught exception: <class 'AttributeError'>: 'Exception' object has no attribute 'getTypes', traceback follows

.)

Change-Id: I4581061dbfa190266fef98dc670a058d6c98eaaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195304
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
(cherry picked from commit d89051d184)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195356
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Stephan Bergmann
2025-12-10 13:49:08 +01:00
committed by Xisco Fauli
parent aa347a75ed
commit de10660813
+1 -2
View File
@@ -606,8 +606,7 @@ lcl_ExceptionMessage(PyObject *const o, OUString const*const pWrapped)
{
OUStringBuffer buf("Couldn't convert ");
PyRef reprString( PyObject_Str(o), SAL_NO_ACQUIRE );
buf.appendAscii( PyUnicode_AsUTF8(reprString.get()) );
buf.append(" to a UNO type");
buf.append(pyString2ustring(reprString.get()) + " to a UNO type");
if (pWrapped)
{
buf.append("; caught exception: " + *pWrapped);