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

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

commit 345f7dec4be8f60a0c0aa7a8c019a22038d45f4c
Author: Jim Jagielski <[email protected]>
AuthorDate: Wed Jul 29 09:55:50 2026 -0400

    Complete the Python 2 to 3 migration across the remaining holdouts
---
 main/configure.ac                                  | 27 +++----
 main/external_deps.lst                             |  6 +-
 main/filter/source/config/fragments/makefile.mk    |  2 +-
 .../source/config/tools/merge/pyAltFCFGMerge       |  2 +-
 main/l10ntools/scripts/makefile.mk                 |  2 +-
 main/l10ntools/scripts/tool/l10ntool.py            |  2 +-
 main/l10ntools/scripts/tool/sdf.py                 |  4 +-
 main/l10ntools/scripts/tool/xhtex.py               | 19 +++--
 main/l10ntools/scripts/tool/xtxex.py               |  4 +-
 main/l10ntools/scripts/xhtex                       |  8 +-
 main/l10ntools/scripts/xtxex                       |  8 +-
 main/pyuno/zipcore/python.sh                       |  2 +-
 main/sc/workben/celltrans/parse.py                 |  2 +-
 main/scp2/source/python/profileitem_python.scp     |  9 +--
 main/solenv/bin/buildalyzer                        | 47 +++++------
 main/solenv/bin/packmodule                         |  2 +-
 main/solenv/bin/pchdelta.py                        |  2 +-
 main/solenv/inc/lldb4aoo.py                        |  9 ++-
 main/testtools/source/bridgetest/pyuno/makefile.mk |  2 +-
 .../source/bridgetest/pyuno/samplecomponent.py     | 94 +++++++++++-----------
 main/toolkit/src2xml/source/expression_test.py     |  2 +-
 main/toolkit/src2xml/source/macroexpander_test.py  |  2 +-
 main/toolkit/src2xml/source/macroparser_test.py    |  2 +-
 main/toolkit/src2xml/source/src2xml.py             |  2 +-
 24 files changed, 128 insertions(+), 133 deletions(-)

diff --git a/main/configure.ac b/main/configure.ac
index 50db0dbb6d..af7e75434d 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -4126,7 +4126,10 @@ if test "$_os" = "Darwin" && test "$with_system_python" 
!= "no"; then
            PYTHON_LIBS="-framework Python"
            ;;
        *)
-           _python_libdir=`$_python -c "import distutils.sysconfig; 
print(distutils.sysconfig.get_config_var('LIBDIR'));"`
+           dnl Use sysconfig, not distutils.sysconfig: distutils was removed in
+           dnl Python 3.12 and the interpreter we pick here may well be newer
+           dnl than the 3.11 floor.
+           _python_libdir=`$_python -c "import sysconfig; 
print(sysconfig.get_config_var('LIBDIR'));"`
            PYTHON_LIBS="-L$_python_libdir -lpython$_python_ver"
            ;;
    esac
@@ -4138,13 +4141,13 @@ elif test -n "$with_system_python" -o -n 
"$with_system_libs" && \
 
    python_include=`$PYTHON -c "import sysconfig; 
print(sysconfig.get_config_var('INCLUDEPY'));"`
    python_version=`$PYTHON -c "import sysconfig; 
print(sysconfig.get_config_var('VERSION'));"`
-   # Python 3.8 and later distinguish building Python modules from linking to 
the libpython:
+   # Python 3.8 and later distinguish building Python modules from linking to 
the
+   # libpython, so embedders must use the "-embed" pkg-config module:
    # (https://bugs.python.org/issue36721)
-   if test "$python_version" -lt "3.8"; then
-       PKG_CHECK_MODULES(PYTHON, python-$python_version, PYTHON_PC="TRUE", 
PYTHON_PC="" )
-   else
-       PKG_CHECK_MODULES(PYTHON, python-$python_version-embed, 
PYTHON_PC="TRUE", PYTHON_PC="" )
-   fi
+   # AM_PATH_PYTHON above already enforces a 3.11 floor, so "-embed" is always
+   # the right variant here. (The old "$python_version" -lt "3.8" test was a
+   # numeric comparison on a string like "3.11" and could never work.)
+   PKG_CHECK_MODULES(PYTHON, python-$python_version-embed, PYTHON_PC="TRUE", 
PYTHON_PC="" )
    if test "$PYTHON_PC" != "TRUE"; then
        PYTHON_CFLAGS="-I$python_include"
        PYTHON_LIBS="-lpython$python_version"
@@ -4166,13 +4169,9 @@ else
    if test "z$HOME" = "z"; then
       export HOME="";
    fi
-   # bz2 tarball and bzip2 is not standard
-   if test -z "$BZIP2"; then
-       AC_PATH_PROG( BZIP2, bzip2)
-       if test -z "$BZIP2"; then
-               AC_MSG_ERROR([the internal Python module has a .tar.bz2. You 
need bzip2])
-       fi
-   fi
+   dnl The internal Python tarball is a .tgz (see main/external_deps.lst), so
+   dnl gzip is all that is needed to unpack it. The old bzip2 requirement was
+   dnl for the Python 2.x .tar.bz2 and no longer applies.
 fi
 AC_SUBST(SYSTEM_PYTHON)
 AC_SUBST(PYTHON_CFLAGS)
diff --git a/main/external_deps.lst b/main/external_deps.lst
index 07a35373ca..598f097564 100644
--- a/main/external_deps.lst
+++ b/main/external_deps.lst
@@ -194,9 +194,9 @@ if (ENABLE_MEDIAWIKI == YES)
     URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
 
 if (SYSTEM_PYTHON != YES)
-    MD5 = 38c84292658ed4456157195f1c9bcbe1
-    name = Python-2.7.18.tgz
-    URL1 = https://www.python.org/ftp/python/2.7.18/$(name)
+    MD5 = 57f84cbd92d478ceff55217d88a07ded
+    name = Python-3.11.15.tgz
+    URL1 = https://www.python.org/ftp/python/3.11.15/$(name)
     URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
 
 if (SYSTEM_BOOST != YES)
diff --git a/main/filter/source/config/fragments/makefile.mk 
b/main/filter/source/config/fragments/makefile.mk
index 2d0d4f3eab..8c879fb5c9 100644
--- a/main/filter/source/config/fragments/makefile.mk
+++ b/main/filter/source/config/fragments/makefile.mk
@@ -142,7 +142,7 @@ $(ALL_FLAGS) : $(INCLUDE_FRAGMENTS)
 .IF "$(SOLAR_JAVA)"==""
 #cmc, hack to workaround the java build requirement
 .IF "$(SYSTEM_PYTHON)" == "YES"
-MERGE:=python ../tools/merge/pyAltFCFGMerge
+MERGE:=python3 ../tools/merge/pyAltFCFGMerge
 .ELSE
 MERGE:=$(AUGMENT_LIBRARY_PATH) $(SOLARBINDIR)/python 
../tools/merge/pyAltFCFGMerge
 .ENDIF
diff --git a/main/filter/source/config/tools/merge/pyAltFCFGMerge 
b/main/filter/source/config/tools/merge/pyAltFCFGMerge
index 1adc1f1aa5..1b178b1f6c 100755
--- a/main/filter/source/config/tools/merge/pyAltFCFGMerge
+++ b/main/filter/source/config/tools/merge/pyAltFCFGMerge
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #_____________________________________________
 # Caolan McNamara [email protected]
 # converted from original java written by Andreas Schluens so we can continue
diff --git a/main/l10ntools/scripts/makefile.mk 
b/main/l10ntools/scripts/makefile.mk
index 612fd0bf60..93c6e84b34 100644
--- a/main/l10ntools/scripts/makefile.mk
+++ b/main/l10ntools/scripts/makefile.mk
@@ -32,7 +32,7 @@ TARGET = l10ntools_dummy_pyc
 .IF "$(SYSTEM_PYTHON)"!="YES"
 PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(SOLARBINDIR)/python
 .ELSE                   # "$(SYSTEM_PYTHON)"!="YES"
-PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) python
+PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) python3
 .ENDIF                  # "$(SYSTEM_PYTHON)"!="YES"
 
 PYFILES = $(BIN)$/const.py \
diff --git a/main/l10ntools/scripts/tool/l10ntool.py 
b/main/l10ntools/scripts/tool/l10ntool.py
index 817e2ad256..e055108daf 100644
--- a/main/l10ntools/scripts/tool/l10ntool.py
+++ b/main/l10ntools/scripts/tool/l10ntool.py
@@ -128,7 +128,7 @@ class AbstractL10nTool:
 
     def extract(self):
         try:
-            f = open(self._options.outputfile, "w+")
+            f = open(self._options.outputfile, "w+", encoding="utf-8")
             f.write(self.extract_file(self._options.inputfile))
         except IOError:
             print("ERROR: Can not write file " + self._options.outputfile)
diff --git a/main/l10ntools/scripts/tool/sdf.py 
b/main/l10ntools/scripts/tool/sdf.py
index eacb1e460e..7d7a5bf9c5 100644
--- a/main/l10ntools/scripts/tool/sdf.py
+++ b/main/l10ntools/scripts/tool/sdf.py
@@ -47,7 +47,7 @@ class SdfData:
 
     def read(self):
         try:
-            f = open(self._filename, "r")
+            f = open(self._filename, "r", encoding="utf-8")
             lines = [line.rstrip('\n') for line in f.readlines()]
         except IOError:
             print("ERROR: Trying to read "+ self._filename)
@@ -62,7 +62,7 @@ class SdfData:
 
     def write(self, filename):
         try:
-            f = open(filename, "w+")
+            f = open(filename, "w+", encoding="utf-8")
             for value in self._dict.values():
                 #f.write( repr(value)+"\n" )
                 f.write(value + "\n")
diff --git a/main/l10ntools/scripts/tool/xhtex.py 
b/main/l10ntools/scripts/tool/xhtex.py
index 6a828b832b..6b9a34a074 100644
--- a/main/l10ntools/scripts/tool/xhtex.py
+++ b/main/l10ntools/scripts/tool/xhtex.py
@@ -50,14 +50,14 @@ class Xhtex(AbstractL10nTool):
             if elem.childNodes[0].nodeType == elem.TEXT_NODE and 
elem.getAttribute("id").strip():
                 obj = self.prepare_sdf_line(inputfile=inputfilename, 
lang=lang, id=elem.getAttribute("id").strip())
                 if sdfdata[obj.get_id()]:
-                    elem.childNodes[0].data = 
unicode(str(sdfdata[obj.get_id()].text),"utf8")
+                    elem.childNodes[0].data = str(sdfdata[obj.get_id()].text)
 
 
     def merge_title(self, list, sdfdata, lang, inputfilename):
         for elem in list:
             obj = self.prepare_sdf_line(inputfile=inputfilename, lang=lang, 
id=elem.getAttribute("id").strip())
             if elem.getAttribute("id").strip() and sdfdata[obj.get_id()]:
-                elem.setAttribute("title", 
unicode(str(sdfdata[obj.get_id()].text),"utf8"))
+                elem.setAttribute("title", str(sdfdata[obj.get_id()].text))
 
     # L10N tool
     def __init__(self):
@@ -66,10 +66,10 @@ class Xhtex(AbstractL10nTool):
     def parse_file(self, filename):
         document = ""
         try:
-            f = open(filename, "r+")
+            f = open(filename, "r+", encoding="utf-8")
             document = f.read()
         except IOError:
-            print "ERROR: Can not read file " + filename
+            print("ERROR: Can not read file " + filename)
             sys.exit(-1)
         else:
             f.close()
@@ -90,11 +90,10 @@ class Xhtex(AbstractL10nTool):
         self.merge_title(dom.getElementsByTagName("help_section"), sdfdata, 
lang, inputfilename)
         self.make_dirs(outputfilename)
         try:
-            f = open(outputfilename, "w+")
-            str = dom.toxml()
-            f.write(str.encode("utf-8"))
+            f = open(outputfilename, "w+", encoding="utf-8")
+            f.write(dom.toxml())
         except IOError:
-            print "ERROR: Can not write file " + outputfilename
+            print("ERROR: Can not write file " + outputfilename)
             sys.exit(-1)
         else:
             f.close()
@@ -103,10 +102,10 @@ class Xhtex(AbstractL10nTool):
     def parse_file(self, filename):
         document = ""
         try:
-            f = open(filename,"r")
+            f = open(filename, "r", encoding="utf-8")
             document = f.read()
         except IOError:
-            print "ERROR: Can not read file " + filename
+            print("ERROR: Can not read file " + filename)
         else:
             f.close()
         return xml.dom.minidom.parseString(document)
diff --git a/main/l10ntools/scripts/tool/xtxex.py 
b/main/l10ntools/scripts/tool/xtxex.py
index 90bd9180d5..86eb97b404 100644
--- a/main/l10ntools/scripts/tool/xtxex.py
+++ b/main/l10ntools/scripts/tool/xtxex.py
@@ -43,7 +43,7 @@ class Xtxex(AbstractL10nTool):
             line = sdfdata[sdfline.get_id()].text.replace("\\n", '\n')
             self.make_dirs(outputfilename)
             try:
-                f = open(outputfilename, "w+")
+                f = open(outputfilename, "w+", encoding="utf-8")
                 f.write(line)
             except IOError:
                 print("ERROR: Can not write file " + outputfilename)
@@ -59,7 +59,7 @@ class Xtxex(AbstractL10nTool):
     def extract_file(self, inputfile):
         lines = []
         try:
-            f = open(inputfile, "r")
+            f = open(inputfile, "r", encoding="utf-8")
             lines = f.readlines()
         except IOError:
             print("ERROR: Can not open file " + inputfile)
diff --git a/main/l10ntools/scripts/xhtex b/main/l10ntools/scripts/xhtex
index 85cc5734e7..1b7bace16e 100755
--- a/main/l10ntools/scripts/xhtex
+++ b/main/l10ntools/scripts/xhtex
@@ -27,14 +27,14 @@ fi
 
 if [ ${GUI} = "WNT" ]; then
 if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx  ]; then
-    exec python $SOLARVERSION/$INPATH/bin/xhtex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin/xhtex.py "$@"
 else
-    exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xhtex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xhtex.py 
"$@"
 fi
 else
 if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx  ]; then
-    exec python $SOLARVERSION/$INPATH/bin/xhtex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin/xhtex.py "$@"
 else
-    exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xhtex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xhtex.py 
"$@"
 fi
 fi
diff --git a/main/l10ntools/scripts/xtxex b/main/l10ntools/scripts/xtxex
index f6966cb307..4dff588c25 100755
--- a/main/l10ntools/scripts/xtxex
+++ b/main/l10ntools/scripts/xtxex
@@ -27,15 +27,15 @@ fi
 
 if [ ${GUI} = "WNT" ]; then
 if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx  ]; then
-    exec python $SOLARVERSION/$INPATH/bin/xtxex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin/xtxex.py "$@"
 else
-    exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xtxex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xtxex.py 
"$@"
 fi
 else
 if [ x${SOLARVER}x = xx -o x${UPDMINOREXT}x = xx  ]; then
-    exec python $SOLARVERSION/$INPATH/bin/xtxex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin/xtxex.py "$@"
 else
-    exec python $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xtxex.py "$@"
+    exec "${PYTHON:-python3}" $SOLARVERSION/$INPATH/bin$UPDMINOREXT/xtxex.py 
"$@"
 fi
 fi
 
diff --git a/main/pyuno/zipcore/python.sh b/main/pyuno/zipcore/python.sh
index 69a8b09c67..d2eb94c1ba 100644
--- a/main/pyuno/zipcore/python.sh
+++ b/main/pyuno/zipcore/python.sh
@@ -50,7 +50,7 @@ export UNO_PATH
 : ${URE_BOOTSTRAP=vnd.sun.star.pathname:$sd_prog/fundamentalrc}
 export URE_BOOTSTRAP
 
-PYTHONPATH=$sd_prog:$sd_prog/python-core-%%PYVERSION%%/lib:$sd_prog/python-core-%%PYVERSION%%/lib/lib-dynload:$sd_prog/python-core-%%PYVERSION%%/lib/lib-tk:$sd_prog/python-core-%%PYVERSION%%/lib/site-packages${PYTHONPATH+:$PYTHONPATH}
+PYTHONPATH=$sd_prog:$sd_prog/python-core-%%PYVERSION%%/lib:$sd_prog/python-core-%%PYVERSION%%/lib/lib-dynload:$sd_prog/python-core-%%PYVERSION%%/lib/site-packages${PYTHONPATH+:$PYTHONPATH}
 export PYTHONPATH
 PYTHONHOME=$sd_prog/python-core-%%PYVERSION%%
 export PYTHONHOME
diff --git a/main/sc/workben/celltrans/parse.py 
b/main/sc/workben/celltrans/parse.py
index 06793fa0d5..b7ccbc5719 100755
--- a/main/sc/workben/celltrans/parse.py
+++ b/main/sc/workben/celltrans/parse.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #**************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/scp2/source/python/profileitem_python.scp 
b/main/scp2/source/python/profileitem_python.scp
index a8e95bb63a..4ae2f5b177 100644
--- a/main/scp2/source/python/profileitem_python.scp
+++ b/main/scp2/source/python/profileitem_python.scp
@@ -67,23 +67,20 @@ ProfileItem gid_Profileitem_Pythonloader_Pythonpath
   #ifdef UNX
     #ifdef MACOSX
     #define FRAMEWORKLIB 
CONCAT4($ORIGIN/OOoPython.framework/Versions/,PYMAJMIN,/lib/python,PYMAJMIN)
-    Value = CONCAT4(FRAMEWORKLIB FRAMEWORKLIB,
+    Value = CONCAT3(FRAMEWORKLIB FRAMEWORKLIB,
                   /lib-dynload FRAMEWORKLIB,
-                  /lib-tk FRAMEWORKLIB,
                   /site-packages $ORIGIN);
     #else
-    Value = CONCAT9($ORIGIN/python-core-,PYVERSION,
+    Value = CONCAT7($ORIGIN/python-core-,PYVERSION,
                   /lib $ORIGIN/python-core-,PYVERSION,
                   /lib/lib-dynload $ORIGIN/python-core-,PYVERSION,
-                  /lib/lib-tk $ORIGIN/python-core-,PYVERSION,
                   /lib/site-packages $ORIGIN);
     #endif
   #else
    #ifdef _gcc3
-    Value = STRING(CONCAT9($ORIGIN/python-core-,PYVERSION,
+    Value = STRING(CONCAT7($ORIGIN/python-core-,PYVERSION,
                   /lib $ORIGIN/python-core-,PYVERSION,
                   /lib/lib-dynload $ORIGIN/python-core-,PYVERSION,
-                  /lib/lib-tk $ORIGIN/python-core-,PYVERSION,
                   /lib/site-packages $ORIGIN));
    #else
     Value = STRING(CONCAT5($ORIGIN/python-core-,PYVERSION,
diff --git a/main/solenv/bin/buildalyzer b/main/solenv/bin/buildalyzer
index 8198ec0bb7..fd50a36b1c 100644
--- a/main/solenv/bin/buildalyzer
+++ b/main/solenv/bin/buildalyzer
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #  
 #  Licensed to the Apache Software Foundation (ASF) under one
@@ -52,18 +52,18 @@ class CxxTarget:
         cxxflags_tmp = dict()
         for flag in self.cxxflags:
             cxxflags_tmp[flag.name] = flag
-        self.cxxflags = cxxflags_tmp.values()
+        self.cxxflags = list(cxxflags_tmp.values())
         includeflags_tmp = dict()
         for flag in self.includeflags:
             includeflags_tmp[flag.name] = flag
-        self.includeflags = includeflags_tmp.values()
+        self.includeflags = list(includeflags_tmp.values())
         CxxTargets.by_name[self.getFullOutputname()] = self
     def __str__(self):
         return '%s' % (self.getFullOutputname())
     def getFullOutputname(self):
         return self.directory + '/' + self.outputfile
-    def __cmp__(self, other):
-        return cmp(self.getFullOutputname(), other.getFullOutputname())
+    def __lt__(self, other):
+        return self.getFullOutputname() < other.getFullOutputname()
 
 class CxxFlag:
     def __init__(self, name):
@@ -71,8 +71,8 @@ class CxxFlag:
         CxxFlags.by_name[self.name] = self
     def __str__(self):
         return 'Flag %s' % (self.name)
-    def __cmp__(self, other):
-        return cmp(self.name, other.name)
+    def __lt__(self, other):
+        return self.name < other.name
 
 class CxxFlags:
     by_name = dict()
@@ -102,8 +102,8 @@ if __name__ == '__main__':
 
     common_compile_flags.sort()
     common_link_flags.sort()
-    print 'common compile flags: %s' % (' '.join(flag.name for flag in 
common_compile_flags))
-    print 'common link flags: %s' % (' '.join(flag.name for flag in 
common_link_flags))
+    print('common compile flags: %s' % (' '.join(flag.name for flag in 
common_compile_flags)))
+    print('common link flags: %s' % (' '.join(flag.name for flag in 
common_link_flags)))
 
     by_flagset = dict()
     for target in CxxTargets.by_name.values():
@@ -113,14 +113,13 @@ if __name__ == '__main__':
         by_flagset[flagset].append(target)
     for targetlist in by_flagset.values():
         targetlist.sort()
-    flagsets = by_flagset.keys()
-    flagsets.sort()
-    print '%d compilerflag groups:' % (len(flagsets))
+    flagsets = sorted(by_flagset.keys())
+    print('%d compilerflag groups:' % (len(flagsets)))
     for flagset in flagsets:
-        print flagset
+        print(flagset)
         for target in by_flagset[flagset]:
-            print '%s' % (target)
-        print
+            print('%s' % (target))
+        print()
 
     by_flagset = dict()
     for target in CxxTargets.by_name.values():
@@ -130,21 +129,19 @@ if __name__ == '__main__':
         by_flagset[flagset].append(target)
     for targetlist in by_flagset.values():
         targetlist.sort()
-    flagsets = by_flagset.keys()
-    flagsets.sort()
-    print '%d include flag groups:' % (len(flagsets))
+    flagsets = sorted(by_flagset.keys())
+    print('%d include flag groups:' % (len(flagsets)))
     for flagset in flagsets:
-        print flagset
+        print(flagset)
         for target in by_flagset[flagset]:
-            print '%s' % (target)
-        print
+            print('%s' % (target))
+        print()
 
-    print 'sources:'
+    print('sources:')
     by_name = dict()
     for target in CxxTargets.by_name.values():
         by_name[os.path.basename(target.outputfile)] = target
-    names = by_name.keys()
-    names.sort()
+    names = sorted(by_name.keys())
     for target in CxxTargets.by_name.values():
         if len(target.inputfiles) > 1:
             objects = [os.path.basename(object) for object in 
target.inputfiles]
@@ -155,4 +152,4 @@ if __name__ == '__main__':
                 else:
                     sources.append('!!!!' + object)
             sources.sort()
-            print '%s %s' % (target.getFullOutputname(), ' '.join(sources))
+            print('%s %s' % (target.getFullOutputname(), ' '.join(sources)))
diff --git a/main/solenv/bin/packmodule b/main/solenv/bin/packmodule
index 6a9d7c9072..325c80d2cd 100755
--- a/main/solenv/bin/packmodule
+++ b/main/solenv/bin/packmodule
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#!/usr/bin/env python3
 #**************************************************************
 #  
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/solenv/bin/pchdelta.py b/main/solenv/bin/pchdelta.py
index 8ef35be2e8..e0f3cc94bd 100755
--- a/main/solenv/bin/pchdelta.py
+++ b/main/solenv/bin/pchdelta.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/solenv/inc/lldb4aoo.py b/main/solenv/inc/lldb4aoo.py
index 7b193a209d..6cd5cac43a 100644
--- a/main/solenv/inc/lldb4aoo.py
+++ b/main/solenv/inc/lldb4aoo.py
@@ -89,10 +89,13 @@ def ret_strdata_info( v, refvar, lenvar, aryvar):
        L = min(l,128)
        d = c.AddressOf().GetPointeeData( 0, L)
        if c.GetByteSize() == 1: # assume UTF-8
-               s = ''.join([chr(x) for x in d.uint8s])
+               s = bytes(bytearray(d.uint8s)).decode('utf-8', 'replace')
        else: # assume UTF-16
-               s = (u''.join([unichr(x) for x in d.uint16s])).encode('utf-8')
-       info += ('{refs=%d, len=%d, str="%s"%s}' % (r, l, 
s.encode('string_escape'), '...'if(l!=L)else''))
+               s = u''.join([chr(x) for x in d.uint16s])
+       # Python 3 has no 'string_escape' codec; 'unicode_escape' is the
+       # equivalent for escaping a str for display.
+       esc = s.encode('unicode_escape').decode('ascii')
+       info += ('{refs=%d, len=%d, str="%s"%s}' % (r, l, esc, 
'...'if(l!=L)else''))
        return info
 
 # definitions for our individual LLDB type summary providers
diff --git a/main/testtools/source/bridgetest/pyuno/makefile.mk 
b/main/testtools/source/bridgetest/pyuno/makefile.mk
index 896451e437..0c74aace14 100644
--- a/main/testtools/source/bridgetest/pyuno/makefile.mk
+++ b/main/testtools/source/bridgetest/pyuno/makefile.mk
@@ -42,7 +42,7 @@ REGEXC=$(DLLDEST)$/regcomp$(EXECPOST)
 .IF "$(SYSTEM_PYTHON)"!="YES"
 PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(SOLARBINDIR)/python
 .ELSE                   # "$(SYSTEM_PYTHON)"!="YES"
-PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) python
+PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) python3
 .ENDIF                  # "$(SYSTEM_PYTHON)"!="YES"
 .IF "$(GUI)"=="WNT"
 
PYTHONPATH:=$(SOLARLIBDIR)$/pyuno;$(PWD);$(SOLARLIBDIR);$(SOLARLIBDIR)$/python;$(SOLARLIBDIR)$/python$/lib-dynload
diff --git a/main/testtools/source/bridgetest/pyuno/samplecomponent.py 
b/main/testtools/source/bridgetest/pyuno/samplecomponent.py
index 3c8b74f2d6..25c3f2ae1c 100644
--- a/main/testtools/source/bridgetest/pyuno/samplecomponent.py
+++ b/main/testtools/source/bridgetest/pyuno/samplecomponent.py
@@ -31,10 +31,10 @@ g_implName = "org.openoffice.comp.pyuno.PythonTestObject"
 
 g_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
             "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
-           "String", "Interface", "Any" , "Sequence" , "Struct"
+            "String", "Interface", "Any" , "Sequence" , "Struct"
 
 def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, 
nHyper,\
-             nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny  ):
+              nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny  ):
     rData.Bool = bBool;
     rData.Char = cChar;
     rData.Byte = nByte;
@@ -53,91 +53,91 @@ def assign( rData, bBool, cChar, nByte, nShort, nUShort, 
nLong, nULong, nHyper,\
 
 class MyRecursiveCall( XRecursiveCall, unohelper.Base ):
       def callRecursivly( xCall, nToCall ):
-         if nToCall:
-            xCall.callRecursivly( self, nToCall -1 )
+          if nToCall:
+             xCall.callRecursivly( self, nToCall -1 )
 
 class SampleUnoComponent( XBridgeTestBase,XServiceInfo ):
       def __init__(self,ctx):
-         self.__dict__["callid"] = 0
-         self.__dict__["sequenceBroken"] = 0
+          self.__dict__["callid"] = 0
+          self.__dict__["sequenceBroken"] = 0
 
       def transportAny( self, value ):
-         return value
+          return value
 
       def raiseException( self, ArgumentPosition, Message, Context ):
-         raise IllegalArgumentException( Message, Context, ArgumentPosition )
+          raise IllegalArgumentException( Message, Context, ArgumentPosition )
 
       def raiseRuntimeExceptionOneway(self, Message, Context ):
-         raise RuntimeException( Message, Context )
+          raise RuntimeException( Message, Context )
 
       def setValues( self, bBool, cChar, nByte, nShort, nUShort, nLong,\
-                    nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, \
-                    aString, xInterface, aAny, aSequence, aStruct ):
+                     nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, \
+                     aString, xInterface, aAny, aSequence, aStruct ):
          self.__dict__["data"] = TestDataElements( bBool, cChar, nByte, 
nShort, nUShort, nLong,
-                         nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, 
aStruct, xInterface,
-                         aAny, aSequence )
+                          nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, 
aStruct, xInterface,
+                          aAny, aSequence )
          self.__dict__["Struct"] = aStruct
 
       def setValues2( self, bBool, cChar, nByte, nShort, nUShort, nLong, 
nULong,\
-                     nHyper, nUHyper, fFloat, fDouble, eEnum,          \
-                     aString, xInterface, aAny, aSequence, aStruct ):
+                      nHyper, nUHyper, fFloat, fDouble, eEnum,         \
+                      aString, xInterface, aAny, aSequence, aStruct ):
           self.__dict__["Struct"] = TestData( cChar, nByte, nShort, nUShort, 
nLong, nULong, nHyper,\
-                                             nUHyper, fFloat, fDouble, eEnum, 
aStruct, xInterface,\
-                                             aAny, aSequence )
+                                              nUHyper, fFloat, fDouble, eEnum, 
aStruct, xInterface,\
+                                              aAny, aSequence )
           self.__dict__["Struct"] = aStruct
-         return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, 
nUHyper, nULong, \
-                nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, 
aAny,           \
-                (aSequence[1],aSequence[0]), aStruct
+          return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, 
nUHyper, nULong, \
+                 nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, 
aAny,          \
+                 (aSequence[1],aSequence[0]), aStruct
 
       def getValues(self, a,b,c,d,e,f,g,h, i,j,k,l,m,n):
-         v = self.__dict__["data"]
-         return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, 
v.UShort, v.Long,     \
-                v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, 
v.String, v.Interface,  \
-                v.Any, v.Sequence, self.__dict__["Struct"]
+          v = self.__dict__["data"]
+          return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, 
v.UShort, v.Long,    \
+                 v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, 
v.String, v.Interface, \
+                 v.Any, v.Sequence, self.__dict__["Struct"]
 
       def call( self, callid, nWaitMUSEC ):
-         if self.__dict__["callid"] >= callid:
-            self.__dict__["sequenceBroken"] = 1
-         else:
-            self.__dict__["callid"] = callid
+          if self.__dict__["callid"] >= callid:
+             self.__dict__["sequenceBroken"] = 1
+          else:
+             self.__dict__["callid"] = callid
 
       def callOneway( self, nCallId, nWaitMUSEC ):
-         call( nCallId, nWaitMUSEC )
+          call( nCallId, nWaitMUSEC )
 
       def sequenceOfCallTestPassed():
-         return self.__dict__["sequenceBroken"]
+          return self.__dict__["sequenceBroken"]
 
       def startRecursiveCall( xCall , nToCall ):
-         if nToCall:
-            xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
+          if nToCall:
+             xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
 
       def checkExistence( self, name ):
-         found = 0
-         for x in g_attribs:
-             if x == name:
-                found = 1
-                break
-         if not found:
-            raise UnknownPropertyException( "Property "+name+" is unknown", 
self )
+          found = 0
+          for x in g_attribs:
+              if x == name:
+                 found = 1
+                 break
+          if not found:
+             raise UnknownPropertyException( "Property "+name+" is unknown", 
self )
 
       def __setattr__( self, name, value ):
-         checkExistence( name )
-         self.__dict__[name] = value
+          checkExistence( name )
+          self.__dict__[name] = value
 
       def __getattr__( self, name ):
-         checkExistence( name )
-         return self.__dict__[name]
+          checkExistence( name )
+          return self.__dict__[name]
 
       def getSupportedServices( self ):
-         return g_ImplementationHelper.getSupportedServices(g_implName)
+          return g_ImplementationHelper.getSupportedServices(g_implName)
       def supportsService( self, ServiceName ):
-         return g_ImplementationHelper.supportsService( g_implName, 
ServiceName )
+          return g_ImplementationHelper.supportsService( g_implName, 
ServiceName )
       def getImplementationName(self):
-         return g_implName
+          return g_implName
 
 
 g_ImplementationHelper.addImplementation( \
-       
SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),)
+        
SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),)
 
 #g_ImplementationEntries = \
 #    unohelper.ImplementationEntry(                            \
diff --git a/main/toolkit/src2xml/source/expression_test.py 
b/main/toolkit/src2xml/source/expression_test.py
index 2458785020..d3f6fc12f8 100644
--- a/main/toolkit/src2xml/source/expression_test.py
+++ b/main/toolkit/src2xml/source/expression_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/toolkit/src2xml/source/macroexpander_test.py 
b/main/toolkit/src2xml/source/macroexpander_test.py
index 56b3f94591..72d2704650 100644
--- a/main/toolkit/src2xml/source/macroexpander_test.py
+++ b/main/toolkit/src2xml/source/macroexpander_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/toolkit/src2xml/source/macroparser_test.py 
b/main/toolkit/src2xml/source/macroparser_test.py
index 596f6034bd..d82fd2b39b 100644
--- a/main/toolkit/src2xml/source/macroparser_test.py
+++ b/main/toolkit/src2xml/source/macroparser_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one
diff --git a/main/toolkit/src2xml/source/src2xml.py 
b/main/toolkit/src2xml/source/src2xml.py
index 5926b09ebd..21291dfdfa 100644
--- a/main/toolkit/src2xml/source/src2xml.py
+++ b/main/toolkit/src2xml/source/src2xml.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # *************************************************************
 #
 #  Licensed to the Apache Software Foundation (ASF) under one

Reply via email to