You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ms...@apache.org on 2020/01/28 14:42:22 UTC

[openoffice] branch AOO42X updated (0f827ae -> d12e928)

This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a change to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git.


    from 0f827ae  Added missing space in help files
     new 3df2737  Workaround most of the Python 3 issues.
     new 12ae179  Workaround most of the Python 3 issues.
     new 8842d6c  pyuno: convert some tabs to spaces
     new b4375c2  scripting: add Python 3 support to the Python provider
     new bee4b99  pyuno: wrap the right entrypoint for Python 3 in the pyuno dlopen wrapper
     new 043e4bd  pyuno: export the entrypoint for Python 3 from libpyuno
     new 2919536  Detect Python's CFLAGS and LIBS using pkg-config when possible.
     new d12e928  gtest patch to allow building with Python 3.

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ext_libraries/gtest/gtest-python3.patch        | 96 ++++++++++++++++++++++++++
 ext_libraries/gtest/makefile.mk                |  2 +-
 main/configure.ac                              |  7 +-
 main/pyuno/Library_pyuno_loader.mk             |  2 +
 main/pyuno/inc/pyuno/pyuno.hxx                 |  4 ++
 main/pyuno/source/loader/pyuno_loader.cxx      |  9 +++
 main/pyuno/source/module/pyuno.cxx             |  6 +-
 main/pyuno/source/module/pyuno_dlopenwrapper.c | 39 ++++++++++-
 main/pyuno/source/module/pyuno_module.cxx      |  2 +-
 main/pyuno/source/module/pyuno_util.cxx        |  2 +-
 main/scripting/source/pyprov/pythonscript.py   | 14 ++--
 11 files changed, 169 insertions(+), 14 deletions(-)
 create mode 100644 ext_libraries/gtest/gtest-python3.patch


[openoffice] 03/08: pyuno: convert some tabs to spaces

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 8842d6ca47c03d8364dbb7b95b2dc2e54e3bccfa
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Wed Jan 15 19:31:08 2020 +0200

    pyuno: convert some tabs to spaces
    
    Patch by: me
    
    (cherry picked from commit 37058acdf5d65adaf7ee2d972967a68be69f5cf1)
---
 main/pyuno/source/loader/pyuno_loader.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main/pyuno/source/loader/pyuno_loader.cxx b/main/pyuno/source/loader/pyuno_loader.cxx
index 6ba2d1c..4768290 100644
--- a/main/pyuno/source/loader/pyuno_loader.cxx
+++ b/main/pyuno/source/loader/pyuno_loader.cxx
@@ -119,8 +119,8 @@ static void setPythonHome ( const OUString & pythonHome )
 #else
     static wchar_t *wpath = Py_DecodeLocale(o.pData->buffer, NULL);
     if (wpath == NULL) {
-    	PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
-	return;
+        PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
+        return;
     }
     Py_SetPythonHome(wpath);
 #endif


[openoffice] 01/08: Workaround most of the Python 3 issues.

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 3df2737ca010ccdeca49710afd6535548f04954b
Author: Pedro Giffuni <pf...@FreeBSD.org>
AuthorDate: Tue Jan 14 21:38:18 2020 -0500

    Workaround most of the Python 3 issues.
    
    (cherry picked from commit d1c4de67fb18833166e1ea82395d623806d5e7a6)
---
 main/pyuno/source/loader/pyuno_loader.cxx | 9 +++++++++
 main/pyuno/source/module/pyuno.cxx        | 6 +++---
 main/pyuno/source/module/pyuno_util.cxx   | 2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/main/pyuno/source/loader/pyuno_loader.cxx b/main/pyuno/source/loader/pyuno_loader.cxx
index f8884d7..62b8460 100644
--- a/main/pyuno/source/loader/pyuno_loader.cxx
+++ b/main/pyuno/source/loader/pyuno_loader.cxx
@@ -113,8 +113,17 @@ static void setPythonHome ( const OUString & pythonHome )
     OUString systemPythonHome;
     osl_getSystemPathFromFileURL( pythonHome.pData, &(systemPythonHome.pData) );
     OString o = rtl::OUStringToOString( systemPythonHome, osl_getThreadTextEncoding() );
+#if PY_MAJOR_VERSION < 3 || PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 4
     rtl_string_acquire(o.pData); // leak this string (thats the api!)
     Py_SetPythonHome( o.pData->buffer);
+#else
+    wchar_t *wpath = Py_DecodeLocale(o.pData->buffer, NULL);
+    if (wpath == NULL) {
+    	PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
+	return;
+    }
+    Py_SetPythonHome(wpath);
+#endif
 }
 
 static void prependPythonPath( const OUString & pythonPathBootstrap )
diff --git a/main/pyuno/source/module/pyuno.cxx b/main/pyuno/source/module/pyuno.cxx
index 38f5782..30506b5 100644
--- a/main/pyuno/source/module/pyuno.cxx
+++ b/main/pyuno/source/module/pyuno.cxx
@@ -450,7 +450,7 @@ PyObject* PyUNO_getattr (PyObject* self, char* name)
 {
     PyUNO* me;
 
-#if PY_VERSION_HEX >= 0x03030000
+#if PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x03060000
     char *name = PyUnicode_AsUTF8(attr_name);
 #elif PY_MAJOR_VERSION >= 3
     PyRef pUtf8(PyUnicode_AsUTF8String(attr_name), SAL_NO_ACQUIRE);
@@ -568,7 +568,7 @@ int PyUNO_setattr (PyObject* self, char* name, PyObject* value)
 {
     PyUNO* me;
 
-#if PY_VERSION_HEX >= 0x03030000
+#if PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x03060000
     char *name = PyUnicode_AsUTF8(attr_name);
 #elif PY_MAJOR_VERSION >= 3
     PyRef pUtf8(PyUnicode_AsUTF8String(attr_name), SAL_NO_ACQUIRE);
@@ -818,7 +818,7 @@ static PyTypeObject PyUNOType =
     NULL,
     NULL,
     (destructor)0
-#if PY_VERSION_HEX >= 0x02060000
+#if PY_VERSION_HEX >= 0x02060000 && PY_VERSION_HEX < 0x03060000
     , 0
 #endif
 };
diff --git a/main/pyuno/source/module/pyuno_util.cxx b/main/pyuno/source/module/pyuno_util.cxx
index 77df033..6cdd7ec 100644
--- a/main/pyuno/source/module/pyuno_util.cxx
+++ b/main/pyuno/source/module/pyuno_util.cxx
@@ -86,7 +86,7 @@ OUString pyString2ustring( PyObject *pystr )
 #if Py_UNICODE_SIZE == 2
 	ret = OUString( (sal_Unicode * ) PyUnicode_AS_UNICODE( pystr ) );
 #else
-#if PY_VERSION_HEX >= 0x03030000
+#if PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x03060000
     Py_ssize_t size;
     char *pUtf8 = PyUnicode_AsUTF8AndSize(pystr, &size);
     ret = OUString(pUtf8, size, RTL_TEXTENCODING_UTF8);


[openoffice] 06/08: pyuno: export the entrypoint for Python 3 from libpyuno

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 043e4bd29f32f6539fd153e5f1e39aa5fb8141b1
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 10:25:34 2020 +0200

    pyuno: export the entrypoint for Python 3 from libpyuno
    
    Patch by: me
    
    (cherry picked from commit 827897c355691c72f37439b8706bc13261c25889)
---
 main/pyuno/inc/pyuno/pyuno.hxx            | 4 ++++
 main/pyuno/source/module/pyuno_module.cxx | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/main/pyuno/inc/pyuno/pyuno.hxx b/main/pyuno/inc/pyuno/pyuno.hxx
index 1245921..cc5e366 100644
--- a/main/pyuno/inc/pyuno/pyuno.hxx
+++ b/main/pyuno/inc/pyuno/pyuno.hxx
@@ -76,7 +76,11 @@
     preconditions: python has been initialized before and
                    the global interpreter lock is held 
 */
+#if PY_MAJOR_VERSION >= 3
+PY_DLLEXPORT PyMODINIT_FUNC PyInit_pyuno();
+#else
 extern "C" PY_DLLEXPORT void SAL_CALL initpyuno();
+#endif
 
 
 namespace pyuno
diff --git a/main/pyuno/source/module/pyuno_module.cxx b/main/pyuno/source/module/pyuno_module.cxx
index e44b0d3..b781035 100644
--- a/main/pyuno/source/module/pyuno_module.cxx
+++ b/main/pyuno/source/module/pyuno_module.cxx
@@ -746,7 +746,7 @@ static struct PyModuleDef PyUNOModule =
 }
 
 #if PY_MAJOR_VERSION >= 3
-extern "C" PyMODINIT_FUNC PyInit_pyuno(void)
+PY_DLLEXPORT PyMODINIT_FUNC PyInit_pyuno()
 {
     PyObject *m;
     


[openoffice] 08/08: gtest patch to allow building with Python 3.

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit d12e9282201a631f4e41c9c584d98b1f338e38d9
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 25 02:59:46 2020 +0200

    gtest patch to allow building with Python 3.
    
    Patch by: me
    
    (cherry picked from commit aec63fa3669010e9bec513e6cd55a25fc335d90e)
---
 ext_libraries/gtest/gtest-python3.patch | 96 +++++++++++++++++++++++++++++++++
 ext_libraries/gtest/makefile.mk         |  2 +-
 2 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/ext_libraries/gtest/gtest-python3.patch b/ext_libraries/gtest/gtest-python3.patch
new file mode 100644
index 0000000..54e7d6f
--- /dev/null
+++ b/ext_libraries/gtest/gtest-python3.patch
@@ -0,0 +1,96 @@
+--- misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py	2020-01-25 02:36:23.509596000 +0200
++++ misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py	2020-01-25 02:50:02.624028000 +0200
+@@ -60,7 +60,10 @@
+ 
+ import os
+ import re
+-import sets
++try:
++    import sets
++except ImportError:
++    pass
+ import sys
+ 
+ # We assume that this file is in the scripts/ directory in the Google
+@@ -90,8 +93,8 @@
+   """
+ 
+   if not os.path.isfile(os.path.join(directory, relative_path)):
+-    print 'ERROR: Cannot find %s in directory %s.' % (relative_path,
+-                                                      directory)
++    print ('ERROR: Cannot find %s in directory %s.' % (relative_path,
++                                                      directory))
+     print ('Please either specify a valid project root directory '
+            'or omit it on the command line.')
+     sys.exit(1)
+@@ -123,7 +126,7 @@
+            (relative_path, output_dir))
+     answer = sys.stdin.readline().strip()
+     if answer not in ['y', 'Y']:
+-      print 'ABORTED.'
++      print ('ABORTED.')
+       sys.exit(1)
+ 
+   # Makes sure the directory holding the output file exists; creates
+@@ -146,8 +149,11 @@
+ def FuseGTestH(gtest_root, output_dir):
+   """Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
+ 
+-  output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
+-  processed_files = sets.Set()  # Holds all gtest headers we've processed.
++  output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
++  if sys.version_info[0] > 2:
++      processed_files = set()
++  else:
++      processed_files = sets.Set()  # Holds all gtest headers we've processed.
+ 
+   def ProcessFile(gtest_header_path):
+     """Processes the given gtest header file."""
+@@ -159,7 +165,7 @@
+     processed_files.add(gtest_header_path)
+ 
+     # Reads each line in the given gtest header.
+-    for line in file(os.path.join(gtest_root, gtest_header_path), 'r'):
++    for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):
+       m = INCLUDE_GTEST_FILE_REGEX.match(line)
+       if m:
+         # It's '#include "gtest/..."' - let's process it recursively.
+@@ -175,7 +181,10 @@
+ def FuseGTestAllCcToFile(gtest_root, output_file):
+   """Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
+ 
+-  processed_files = sets.Set()
++  if sys.version_info[0] > 2:
++      processed_files = set()
++  else:
++      processed_files = sets.Set()
+ 
+   def ProcessFile(gtest_source_file):
+     """Processes the given gtest source file."""
+@@ -187,7 +196,7 @@
+     processed_files.add(gtest_source_file)
+ 
+     # Reads each line in the given gtest source file.
+-    for line in file(os.path.join(gtest_root, gtest_source_file), 'r'):
++    for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
+       m = INCLUDE_GTEST_FILE_REGEX.match(line)
+       if m:
+         if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
+@@ -218,7 +227,7 @@
+ def FuseGTestAllCc(gtest_root, output_dir):
+   """Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
+ 
+-  output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
++  output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
+   FuseGTestAllCcToFile(gtest_root, output_file)
+   output_file.close()
+ 
+@@ -242,7 +251,7 @@
+     # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
+     FuseGTest(sys.argv[1], sys.argv[2])
+   else:
+-    print __doc__
++    print (__doc__)
+     sys.exit(1)
+ 
+ 
diff --git a/ext_libraries/gtest/makefile.mk b/ext_libraries/gtest/makefile.mk
index 0b811e5..4c0b1c4 100644
--- a/ext_libraries/gtest/makefile.mk
+++ b/ext_libraries/gtest/makefile.mk
@@ -46,7 +46,7 @@ TARFILE_NAME=$(PRJNAME)-$(LIBGTESTVERSION)
 # thankfully, does not care.
 TARFILE_MD5=2d6ec8ccdf5c46b05ba54a9fd1d130d7
 
-PATCH_FILES= use-own-tuple.patch
+PATCH_FILES= use-own-tuple.patch gtest-python3.patch
 
 .IF "$(OS)"=="WNT"
 


[openoffice] 05/08: pyuno: wrap the right entrypoint for Python 3 in the pyuno dlopen wrapper

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit bee4b9955243a08e7572e1fc52f40544baf3c55f
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 10:20:44 2020 +0200

    pyuno: wrap the right entrypoint for Python 3 in the pyuno dlopen wrapper
    
    Patch by: me
    
    (cherry picked from commit 29716487c9dd2d298fa194b73f148072e7f0a3e7)
---
 main/pyuno/Library_pyuno_loader.mk             |  2 ++
 main/pyuno/source/module/pyuno_dlopenwrapper.c | 39 ++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/main/pyuno/Library_pyuno_loader.mk b/main/pyuno/Library_pyuno_loader.mk
index afbea6f..c13cee7 100644
--- a/main/pyuno/Library_pyuno_loader.mk
+++ b/main/pyuno/Library_pyuno_loader.mk
@@ -38,6 +38,8 @@ else ifeq ($(OS),MACOSX)
 $(eval $(call gb_Library_add_libs,pyuno_loader,-ldl))
 endif
 
+$(call gb_Library_use_external,pyuno_loader,python)
+
 $(eval $(call gb_Library_add_cobjects,pyuno_loader,\
 	pyuno/source/module/pyuno_dlopenwrapper \
 ))
diff --git a/main/pyuno/source/module/pyuno_dlopenwrapper.c b/main/pyuno/source/module/pyuno_dlopenwrapper.c
index beef85b..bb6614c 100644
--- a/main/pyuno/source/module/pyuno_dlopenwrapper.c
+++ b/main/pyuno/source/module/pyuno_dlopenwrapper.c
@@ -21,6 +21,22 @@
 
 
 
+#ifndef Py_PYTHON_H
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#ifdef _DEBUG
+#undef _DEBUG
+#include <Python.h>
+#define _DEBUG
+#else
+#include <Python.h>
+#endif // #ifdef _DEBUG
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#endif // #ifdef Py_PYTHON_H
+
 #include <rtl/string.h>
 
 #include <stdlib.h>
@@ -33,12 +49,24 @@
 #endif
 #include <dlfcn.h>
 
+#if PY_MAJOR_VERSION >= 3
+SAL_DLLPUBLIC_EXPORT void* PyInit_pyuno(void)
+#else
 SAL_DLLPUBLIC_EXPORT void initpyuno ()
+#endif
 {
     Dl_info dl_info;
+#if PY_MAJOR_VERSION >= 3
+    void* (*func)(void);
+#else
     void (*func)(void);
+#endif
 
+#if PY_MAJOR_VERSION >= 3
+    if (dladdr((void*)&PyInit_pyuno, &dl_info) != 0) {
+#else
     if (dladdr((void*)&initpyuno, &dl_info) != 0) { 
+#endif
         void* h = 0;
 	size_t len = strrchr(dl_info.dli_fname, '/') - dl_info.dli_fname + 1;
 	char* libname = malloc(len + RTL_CONSTASCII_LENGTH( SAL_DLLPREFIX "pyuno" SAL_DLLEXTENSION ) + 1);
@@ -49,8 +77,15 @@ SAL_DLLPUBLIC_EXPORT void initpyuno ()
 	free(libname);
         if( h )
         {
-            func = (void (*)())dlsym (h, "initpyuno");
-            (func) ();
+#if PY_MAJOR_VERSION >= 3
+            func = (void* (*)(void))dlsym (h, "PyInit_pyuno");
+#else
+            func = (void (*)(void))dlsym (h, "initpyuno");
+#endif
+            return (func) ();
         }
     } 
+#if PY_MAJOR_VERSION >= 3
+    return NULL;
+#endif
 }


[openoffice] 07/08: Detect Python's CFLAGS and LIBS using pkg-config when possible.

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 2919536114762ddf4d9608d31112b8e01ef4b937
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 25 02:11:54 2020 +0200

    Detect Python's CFLAGS and LIBS using pkg-config when possible.
    
    This fixes linking to Python on FreeBSD with Python 3.
    
    Patch by: me
    
    (cherry picked from commit 00503fad63e905b0ef1d175bb9780a358bc27263)
---
 main/configure.ac | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/main/configure.ac b/main/configure.ac
index 4ec5594..d6e943e 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -4010,8 +4010,11 @@ elif test -n "$with_system_python" -o -n "$with_system_libs" && \
 
    python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
    python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
-   PYTHON_CFLAGS="-I$python_include"
-   PYTHON_LIBS="-lpython$python_version"
+   PKG_CHECK_MODULES(PYTHON, python-$python_version, PYTHON_PC="TRUE", PYTHON_PC="" )
+   if test "$PYTHON_PC" != "TRUE"; then
+       PYTHON_CFLAGS="-I$python_include"
+       PYTHON_LIBS="-lpython$python_version"
+   fi
 fi
 if test "$with_system_python" = "yes" ; then
    SYSTEM_PYTHON=YES


[openoffice] 04/08: scripting: add Python 3 support to the Python provider

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit b4375c204007c475db6255f030c4d5f60ed834dd
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 09:52:51 2020 +0200

    scripting: add Python 3 support to the Python provider
    
    Patch by: me
    
    (cherry picked from commit 4f686187ecfc86b8d293f1b6c9a49fee4b0bf393)
---
 main/scripting/source/pyprov/pythonscript.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/main/scripting/source/pyprov/pythonscript.py b/main/scripting/source/pyprov/pythonscript.py
index 23e82b5..af01bb0 100644
--- a/main/scripting/source/pyprov/pythonscript.py
+++ b/main/scripting/source/pyprov/pythonscript.py
@@ -56,7 +56,10 @@ ENABLE_EDIT_DIALOG=False                    # offers a minimal editor for editin
 #-------------------------------------------------------------------
 
 def encfile(uni):
-    return uni.encode( sys.getfilesystemencoding())
+    if sys.version_info[0] > 2:
+        return uni
+    else:
+        return uni.encode( sys.getfilesystemencoding())
 
 def lastException2String():
     (excType,excInstance,excTraceback) = sys.exc_info()
@@ -81,7 +84,7 @@ def getLogTarget():
             userInstallation =  pathSubst.getSubstituteVariableValue( "user" )
             if len( userInstallation ) > 0:
                 systemPath = uno.fileUrlToSystemPath( userInstallation + "/Scripts/python/log.txt" )
-                ret = file( systemPath , "a" )
+                ret = open( systemPath , "a" )
         except Exception as e:
             print("Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delagating log to stdout\n")
     return ret
@@ -153,13 +156,16 @@ g_implName = "org.openoffice.pyuno.LanguageScriptProviderFor"+LANGUAGENAME
 BLOCK_SIZE = 65536
 def readTextFromStream( inputStream ):
     # read the file
-    code = uno.ByteSequence( "" )
+    code = uno.ByteSequence( b"" )
     while True:
         read,out = inputStream.readBytes( None , BLOCK_SIZE )
         code = code + out
         if read < BLOCK_SIZE:
             break
-    return code.value
+    if sys.version_info[0] > 2:
+        return str( code.value, 'utf-8' )
+    else:
+        return code.value
 
 def toIniName( str ):
     # TODO: what is the official way to get to know whether i am on the windows platform ?


[openoffice] 02/08: Workaround most of the Python 3 issues.

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 12ae17966a29cfdb844f2f0ef63118c662a57c66
Author: Pedro Giffuni <pf...@FreeBSD.org>
AuthorDate: Wed Jan 15 00:42:50 2020 -0500

    Workaround most of the Python 3 issues.
    
    (cherry picked from commit 3fca2ba9cd48b30a6c5f46ea5e1c985440d981d7)
---
 main/pyuno/source/loader/pyuno_loader.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/pyuno/source/loader/pyuno_loader.cxx b/main/pyuno/source/loader/pyuno_loader.cxx
index 62b8460..6ba2d1c 100644
--- a/main/pyuno/source/loader/pyuno_loader.cxx
+++ b/main/pyuno/source/loader/pyuno_loader.cxx
@@ -117,7 +117,7 @@ static void setPythonHome ( const OUString & pythonHome )
     rtl_string_acquire(o.pData); // leak this string (thats the api!)
     Py_SetPythonHome( o.pData->buffer);
 #else
-    wchar_t *wpath = Py_DecodeLocale(o.pData->buffer, NULL);
+    static wchar_t *wpath = Py_DecodeLocale(o.pData->buffer, NULL);
     if (wpath == NULL) {
     	PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
 	return;