summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorjan Iversen <jani@documentfoundation.org>2016-12-25 09:52:56 +0100
committerjan Iversen <jani@documentfoundation.org>2016-12-25 18:26:06 +0100
commitbfbc5e539ff3e20473879cf57244befc0256f543 (patch)
treeb06d4af6e343261b1f9d96732a089e73ea13f7ef /pyuno
parent74fdcfdfd30460f6e15461ed94ff7b14f6d432b3 (diff)
pyuno osx Sierra problem.
On a fresh installed Sierra pyuno fails to build due to a py_UNICODE conversion problem. Py_UNICODE expand to "unsigned short", and OUString expect a form of sal_UNICODE The hack was done locally and not generally expand OUString functionality. Change-Id: Ib7834c423c1c5cd9cd1e8d1ed8393e80bf8a5e5d
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);