summaryrefslogtreecommitdiffstats
path: root/pyuno
diff options
context:
space:
mode:
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno_util.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index e61ff77cfd7f..1fd282053b80 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -40,7 +40,16 @@ PyRef ustring2PyUnicode( const OUString & str )
PyRef ret;
#if Py_UNICODE_SIZE == 2
// YD force conversion since python/2 uses wchar_t
+#ifdef MACOSX
+ // on Sierra, python 2.7 (builtin)
+ // no known conversion from 'const sal_Unicode *' (aka 'const char16_t *') to
+ // 'const Py_UNICODE *' (aka 'const unsigned short *')
+ // An explicit cast to sal_Unicode does not work
+ // Hack to avoid that error
+ ret = PyRef( PyUnicode_FromUnicode( (const unsigned short *)str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
+#else
ret = PyRef( PyUnicode_FromUnicode( str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
+#endif
#else
OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), nullptr) , SAL_NO_ACQUIRE );
@@ -60,7 +69,15 @@ OUString pyString2ustring( PyObject *pystr )
if( PyUnicode_Check( pystr ) )
{
#if Py_UNICODE_SIZE == 2
+#ifdef MACOSX
+ // on Sierra, python 2.7 (builtin)
+ // no known conversion from 'Py_UNICODE *' (aka 'unsigned short *') to
+ // 'sal_Unicode' (aka 'char16_t') for 1st argument
+ // Hack to avoid that error
+ ret = OUString( (sal_Unicode *)PyUnicode_AS_UNICODE( pystr ) );
+#else
ret = OUString( PyUnicode_AS_UNICODE( pystr ) );
+#endif
#else
#if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0);