summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/update_pch_bisect2
-rw-r--r--configure.ac12
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py17
-rw-r--r--pyuno/inc/pyuno.hxx7
-rw-r--r--pyuno/qa/pytests/testcollections_misc2.py22
-rw-r--r--pyuno/source/loader/pythonloader.py5
-rw-r--r--pyuno/source/loader/pyuno_loader.cxx9
-rw-r--r--pyuno/source/module/pyuno.cxx26
-rw-r--r--pyuno/source/module/pyuno_dlopenwrapper.c10
-rw-r--r--pyuno/source/module/pyuno_impl.hxx45
-rw-r--r--pyuno/source/module/pyuno_module.cxx10
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx36
-rw-r--r--pyuno/source/module/pyuno_type.cxx4
-rw-r--r--pyuno/source/module/pyuno_util.cxx10
-rw-r--r--pyuno/source/module/uno.py22
-rw-r--r--scripting/source/pyprov/mailmerge.py22
-rw-r--r--scripting/source/pyprov/pythonscript.py8
-rwxr-xr-xsolenv/bin/version.py1
-rw-r--r--solenv/gbuild/gen-autoinstall.py2
-rw-r--r--unotest/source/python/org/libreoffice/unotest.py2
-rw-r--r--wizards/source/access2base/access2base.py2
-rw-r--r--writerfilter/source/ooxml/factory_ns.py1
-rw-r--r--writerfilter/source/ooxml/factoryimpl.py1
-rw-r--r--writerfilter/source/ooxml/factoryimpl_ns.py1
-rw-r--r--writerfilter/source/ooxml/factoryinc.py1
-rw-r--r--writerfilter/source/ooxml/modelpreprocess.py1
-rw-r--r--writerfilter/source/ooxml/qnametostr.py1
-rw-r--r--writerfilter/source/ooxml/resourceids.py1
28 files changed, 29 insertions, 252 deletions
diff --git a/bin/update_pch_bisect b/bin/update_pch_bisect
index 07f0dbb650ae..8c86ac3cc2db 100755
--- a/bin/update_pch_bisect
+++ b/bin/update_pch_bisect
@@ -27,8 +27,6 @@ compile, which it identifies.
Usage: ./bin/update_pch_bisect ./vcl/inc/pch/precompiled_vcl.hxx "make vcl.build" --find-required --verbose
"""
-from __future__ import print_function
-
import sys
import re
import os
diff --git a/configure.ac b/configure.ac
index 5447d184fc3f..b8b40177e98e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8788,8 +8788,7 @@ AC_SUBST(LIBXML_LIBS)
AC_SUBST(XMLLINT)
# =====================================================================
-# Checking for a Python interpreter with version >= 2.7.
-# Build and runtime requires Python 3 compatible version (>= 2.7).
+# Checking for a Python interpreter with version >= 3.3.
# Optionally user can pass an option to configure, i. e.
# ./configure PYTHON=/usr/bin/python
# =====================================================================
@@ -8798,7 +8797,7 @@ if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
PYTHON_FOR_BUILD=$PYTHON
else
# This allows a lack of system python with no error, we use internal one in that case.
- AM_PATH_PYTHON([2.7],, [:])
+ AM_PATH_PYTHON([3.3],, [:])
# Clean PYTHON_VERSION checked below if cross-compiling
PYTHON_VERSION=""
if test "$PYTHON" != ":"; then
@@ -8863,7 +8862,7 @@ fully-internal)
system)
AC_MSG_RESULT([system])
if test "$_os" = Darwin; then
- AC_MSG_ERROR([--enable-python=system doesn't work on macOS: /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h is known to contain uses of "register", which is removed from C++17])
+ AC_MSG_ERROR([--enable-python=system doesn't work on macOS because the version provided is obsolete])
fi
;;
*)
@@ -8981,11 +8980,10 @@ system)
#include <Python.h>
int main(int argc, char **argv) {
- if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 7) ||
- (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
+ if ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
else return 1;
}
- ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3, or Python >= 2.7 when building with Python 2])],[AC_MSG_RESULT([skipped; cross-compiling])])
+ ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3])],[AC_MSG_RESULT([skipped; cross-compiling])])
CFLAGS=$save_CFLAGS
AC_LANG_POP(C)
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index 2fa16ed81822..859b62e19532 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -6,17 +6,10 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import unicode_literals
import sys, os, uno, unohelper
import re, random, traceback, itertools
import threading, time as __time__
-try:
- unicode
- next = lambda l: l.next() # python 2
-except:
- unicode, long = str, int # support python 3
-
__lng__ = {}
def __trace__():
@@ -327,7 +320,7 @@ def __string__(s, decimal = None): # convert decimal sign, localized BOOL and SE
s = s.replace(".", ",")
return re.sub(__DECODE_STRING_REGEX__, __decodestring__, \
s.replace('set', __locname__('SET')).replace('True', __locname__('TRUE')).replace('False', __locname__('FALSE')))
- if type(s) in [str, unicode]:
+ if type(s) in [str]:
return s
elif type(s) == bool:
return __locname__(str(s).upper())
@@ -1323,9 +1316,9 @@ def __fontstyle__(w):
return __Slant_NONE__
def __color__(c):
- if type(c) in [int, float, long]:
+ if type(c) in [int, float]:
return c
- if type(c) == unicode:
+ if type(c) == str:
if c == u'any':
rc, rv, rgray = __NORMCOLORS__[int(random.random()*7)], random.random(), random.random() ** 0.5
ratio = 1.0*abs(rc[2])/(abs(rc[2]) + abs(rc[4]))
@@ -1610,12 +1603,12 @@ def __groupend__(name = ""):
__removeshape__(__ACTUAL__)
def __int__(x): # handle eg. int("10cm")
- if type(x) == str or type(x) == unicode:
+ if type(x) == str:
x = __float__(x)
return int(x)
def __float__(x): # handle eg. float("10,5cm")
- if type(x) == str or type(x) == unicode:
+ if type(x) == str:
for i in __comp__[_.lng]:
x = re.sub(u"(?iu)" + i[0], i[1], x)
x = eval(x)
diff --git a/pyuno/inc/pyuno.hxx b/pyuno/inc/pyuno.hxx
index c190cfc348c2..f7cab36c7327 100644
--- a/pyuno/inc/pyuno.hxx
+++ b/pyuno/inc/pyuno.hxx
@@ -53,12 +53,7 @@ namespace com::sun::star::uno { template <typename > class Reference; }
the global interpreter lock is held
*/
-extern "C" LO_DLLPUBLIC_PYUNO
-#if PY_MAJOR_VERSION >= 3
- PyObject* PyInit_pyuno();
-#else
- void initpyuno();
-#endif
+extern "C" LO_DLLPUBLIC_PYUNO PyObject* PyInit_pyuno();
namespace pyuno
{
diff --git a/pyuno/qa/pytests/testcollections_misc2.py b/pyuno/qa/pytests/testcollections_misc2.py
index 8566d2838e81..b696e050a53d 100644
--- a/pyuno/qa/pytests/testcollections_misc2.py
+++ b/pyuno/qa/pytests/testcollections_misc2.py
@@ -35,28 +35,18 @@ class Test124953(unittest.TestCase):
self.assertEqual(LONG_TYPE, long_type)
def test_Char(self):
- if sys.version_info[0] == 3:
- char_a = uno.Char("a")
- char_a2 = uno.Char("a")
- char_b = uno.Char("b")
- else:
- char_a = uno.Char(u"a")
- char_a2 = uno.Char(u"a")
- char_b = uno.Char(u"b")
+ char_a = uno.Char("a")
+ char_a2 = uno.Char("a")
+ char_b = uno.Char("b")
self.assertEqual(char_a, char_a)
self.assertEqual(char_a, char_a2)
self.assertFalse((char_a != char_a2))
self.assertNotEqual(char_a, char_b)
def test_ByteSequence(self):
- if sys.version_info[0] == 3:
- b1 = uno.ByteSequence(bytes("abcdefg", encoding="utf8"))
- b2 = uno.ByteSequence(bytes("abcdefg", encoding="utf8"))
- b3 = uno.ByteSequence(bytes("1234567", encoding="utf8"))
- else:
- b1 = uno.ByteSequence("abcdefg")
- b2 = uno.ByteSequence("abcdefg")
- b3 = uno.ByteSequence("1234567")
+ b1 = uno.ByteSequence(bytes("abcdefg", encoding="utf8"))
+ b2 = uno.ByteSequence(bytes("abcdefg", encoding="utf8"))
+ b3 = uno.ByteSequence(bytes("1234567", encoding="utf8"))
self.assertEqual(b1, b1)
self.assertEqual(b1, b2)
self.assertFalse(b1 != b2)
diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py
index 5ce69f62ea7e..4233c0e7ca6e 100644
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -90,10 +90,7 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
# read the file
filename = unohelper.fileUrlToSystemPath( url )
- if sys.version_info >= (3,0):
- fileHandle = open( filename, encoding='utf_8' )
- else:
- fileHandle = open( filename )
+ fileHandle = open( filename, encoding='utf_8' )
src = fileHandle.read().replace("\r","")
if not src.endswith( "\n" ):
src = src + "\n"
diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index c7b7b7289b86..8556dfdde11f 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -121,7 +121,6 @@ static void setPythonHome ( const OUString & pythonHome )
OUString systemPythonHome;
osl_getSystemPathFromFileURL( pythonHome.pData, &(systemPythonHome.pData) );
OString o = OUStringToOString( systemPythonHome, osl_getThreadTextEncoding() );
-#if PY_MAJOR_VERSION >= 3
// static because Py_SetPythonHome just copies the "wide" pointer
static wchar_t wide[PATH_MAX + 1];
size_t len = mbstowcs(wide, o.pData->buffer, PATH_MAX + 1);
@@ -136,10 +135,6 @@ static void setPythonHome ( const OUString & pythonHome )
return;
}
Py_SetPythonHome(wide);
-#else
- rtl_string_acquire(o.pData); // increase reference count
- Py_SetPythonHome(o.pData->buffer);
-#endif
}
static void prependPythonPath( const OUString & pythonPathBootstrap )
@@ -216,11 +211,7 @@ PythonInit() {
osl_setEnvironment(sEnvName.pData, sPath.pData);
#endif
-#if PY_MAJOR_VERSION >= 3
PyImport_AppendInittab( "pyuno", PyInit_pyuno );
-#else
- PyImport_AppendInittab( (char*)"pyuno", initpyuno );
-#endif
#if HAVE_FEATURE_READONLY_INSTALLSET
Py_DontWriteBytecodeFlag = 1;
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index bf6e5c667b7c..1b76a3fb6a9d 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -317,14 +317,9 @@ static sal_Int32 lcl_PyNumber_AsSal_Int32( PyObject *pObj )
// Convert Python number to platform long, then check actual value against
// bounds of sal_Int32
-#if PY_VERSION_HEX >= 0x03020000
int nOverflow;
long nResult = PyLong_AsLongAndOverflow( pObj, &nOverflow );
if ( nOverflow || nResult > SAL_MAX_INT32 || nResult < SAL_MIN_INT32) {
-#else
- long nResult = PyLong_AsLong( pObj );
- if ( nResult > SAL_MAX_INT32 || nResult < SAL_MIN_INT32) {
-#endif
PyErr_SetString( PyExc_IndexError, "Python int too large to convert to UNO long" );
return -1;
}
@@ -336,14 +331,8 @@ static int lcl_PySlice_GetIndicesEx( PyObject *pObject, sal_Int32 nLen, sal_Int3
{
Py_ssize_t nStart_ssize, nStop_ssize, nStep_ssize, nSliceLength_ssize;
- int nResult =
-#if PY_VERSION_HEX >= 0x030200f0
- PySlice_GetIndicesEx(pObject,
+ int nResult = PySlice_GetIndicesEx(pObject,
nLen, &nStart_ssize, &nStop_ssize, &nStep_ssize, &nSliceLength_ssize );
-#else
- PySlice_GetIndicesEx(reinterpret_cast<PySliceObject*>(pObject),
- nLen, &nStart_ssize, &nStop_ssize, &nStep_ssize, &nSliceLength_ssize );
-#endif
if (nResult == -1)
return -1;
@@ -1554,9 +1543,6 @@ static PyNumberMethods PyUNONumberMethods[] =
nullptr, /* nb_add */
nullptr, /* nb_subtract */
nullptr, /* nb_multiply */
-#if PY_MAJOR_VERSION < 3
- nullptr, /* nb_divide */
-#endif
nullptr, /* nb_remainder */
nullptr, /* nb_divmod */
nullptr, /* nb_power */
@@ -1570,22 +1556,12 @@ static PyNumberMethods PyUNONumberMethods[] =
nullptr, /* nb_and */
nullptr, /* nb_xor */
nullptr, /* nb_or */
-#if PY_MAJOR_VERSION < 3
- nullptr, /* nb_coerce */
-#endif
nullptr, /* nb_int */
nullptr, /* nb_reserved */
nullptr, /* nb_float */
-#if PY_MAJOR_VERSION < 3
- nullptr, /* nb_oct */
- nullptr, /* nb_hex */
-#endif
nullptr, /* nb_inplace_add */
nullptr, /* nb_inplace_subtract */
nullptr, /* nb_inplace_multiply */
-#if PY_MAJOR_VERSION < 3
- nullptr, /* nb_inplace_divide */
-#endif
nullptr, /* nb_inplace_remainder */
nullptr, /* nb_inplace_power */
nullptr, /* nb_inplace_lshift */
diff --git a/pyuno/source/module/pyuno_dlopenwrapper.c b/pyuno/source/module/pyuno_dlopenwrapper.c
index 44e711653e35..78e6982e8945 100644
--- a/pyuno/source/module/pyuno_dlopenwrapper.c
+++ b/pyuno/source/module/pyuno_dlopenwrapper.c
@@ -76,19 +76,9 @@ static void * load(void const * address, char const * symbol) {
return func;
}
-#if PY_MAJOR_VERSION >= 3
-
SAL_DLLPUBLIC_EXPORT PyObject * PyInit_pyuno(void) {
return
((PyObject * (*)(void)) load((void *) &PyInit_pyuno, "PyInit_pyuno"))();
}
-#else
-
-SAL_DLLPUBLIC_EXPORT void initpyuno(void) {
- ((void (*)(void)) load((void *) &initpyuno, "initpyuno"))();
-}
-
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/pyuno/source/module/pyuno_impl.hxx b/pyuno/source/module/pyuno_impl.hxx
index a1ac6fbf92fd..44d6bb8985a6 100644
--- a/pyuno/source/module/pyuno_impl.hxx
+++ b/pyuno/source/module/pyuno_impl.hxx
@@ -26,15 +26,6 @@
#include <Python.h>
-#if PY_VERSION_HEX < 0x03020000
-typedef long Py_hash_t;
-#endif
-
-//Must define PyVarObject_HEAD_INIT for Python 2.5 or older
-#ifndef PyVarObject_HEAD_INIT
-#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
-#endif
-
//Python 3.0 and newer don't have these flags
#ifndef Py_TPFLAGS_HAVE_ITER
# define Py_TPFLAGS_HAVE_ITER 0
@@ -71,7 +62,6 @@ namespace com::sun::star::script { class XTypeConverter; }
// In Python 3, the PyString_* functions have been replaced by PyBytes_*
// and PyUnicode_* functions.
-#if PY_MAJOR_VERSION >= 3
// compatibility wrappers for Python "str" type (PyUnicode in 3, PyString in 2)
inline PyObject* PyStr_FromString(const char *string)
@@ -110,41 +100,6 @@ inline PyObject* PyStrBytes_FromStringAndSize(const char *string, Py_ssize_t len
{
return PyBytes_FromStringAndSize(string, len);
}
-#else
-inline char * PyStr_AsString(PyObject *object)
-{
- return PyString_AsString(object);
-}
-
-inline PyObject* PyStr_FromString(const char *string)
-{
- return PyString_FromString(string);
-}
-
-inline bool PyStr_Check(PyObject *object)
-{
- return PyString_Check(object);
-}
-inline bool PyStrBytes_Check(PyObject *object)
-{
- return PyString_Check(object);
-}
-
-inline char* PyStrBytes_AsString(PyObject *object)
-{
- return PyString_AsString(object);
-}
-
-inline Py_ssize_t PyStrBytes_Size(PyObject *object)
-{
- return PyString_Size(object);
-}
-
-inline PyObject* PyStrBytes_FromStringAndSize(const char *string, Py_ssize_t len)
-{
- return PyString_FromStringAndSize(string, len);
-}
-#endif /* PY_MAJOR_VERSION >= 3 */
namespace pyuno
{
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index 4abe28b84539..df7874467503 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -877,7 +877,6 @@ struct PyMethodDef PyUNOModule_methods [] =
}
extern "C"
-#if PY_MAJOR_VERSION >= 3
PyObject* PyInit_pyuno()
{
PyUNO_initType();
@@ -898,14 +897,5 @@ PyObject* PyInit_pyuno()
};
return PyModule_Create(&moduledef);
}
-#else
-void initpyuno()
-{
- PyUNO_initType();
- PyUNOStruct_initType();
- PyEval_InitThreads();
- Py_InitModule ("pyuno", PyUNOModule_methods);
-}
-#endif /* PY_MAJOR_VERSION >= 3 */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 9b6eb22d4e06..ba0f5adefa98 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -642,41 +642,8 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
{
}
- // In Python 3, there is no PyInt type.
-#if PY_MAJOR_VERSION < 3
- else if (PyInt_Check (o))
- {
- if( o == Py_True )
- {
- a <<= true;
- }
- else if ( o == Py_False )
- {
- a <<= false;
- }
- else
- {
- sal_Int32 l = (sal_Int32) PyLong_AsLong( o );
- if( l < 128 && l >= -128 )
- {
- sal_Int8 b = (sal_Int8 ) l;
- a <<= b;
- }
- else if( l <= 0x7fff && l >= -0x8000 )
- {
- sal_Int16 s = (sal_Int16) l;
- a <<= s;
- }
- else
- {
- a <<= l;
- }
- }
- }
-#endif /* PY_MAJOR_VERSION < 3 */
else if (PyLong_Check (o))
{
-#if PY_MAJOR_VERSION >= 3
// Convert the Python 3 booleans that are actually of type PyLong.
if(o == Py_True)
{
@@ -688,7 +655,6 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
}
else
{
-#endif /* PY_MAJOR_VERSION >= 3 */
sal_Int64 l = static_cast<sal_Int64>(PyLong_AsLong (o));
if( l < 128 && l >= -128 )
{
@@ -710,9 +676,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
{
a <<= l;
}
-#if PY_MAJOR_VERSION >= 3
}
-#endif
}
else if (PyFloat_Check (o))
{
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index de4a212e22bb..19de9430a360 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -134,11 +134,7 @@ sal_Unicode PyChar2Unicode( PyObject *obj )
"attribute value of uno.Char is not a unicode string" );
}
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3
if( PyUnicode_GetLength( value.get() ) < 1 )
-#else
- if( PyUnicode_GetSize( value.get() ) < 1 )
-#endif
{
throw RuntimeException(
"uno.Char contains an empty unicode string");
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index f1eebff90345..3d4f452103a3 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -63,24 +63,14 @@ OUString pyString2ustring( PyObject *pystr )
ret = OUString(
reinterpret_cast<sal_Unicode const *>(PyUnicode_AS_UNICODE( pystr )) );
#else
-#if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0);
char const *pUtf8(PyUnicode_AsUTF8AndSize(pystr, &size));
ret = OUString(pUtf8, size, RTL_TEXTENCODING_UTF8);
-#else
- PyObject* pUtf8 = PyUnicode_AsUTF8String(pystr);
- ret = OUString(PyStr_AsString(pUtf8), PyString_Size(pUtf8), RTL_TEXTENCODING_UTF8);
- Py_DECREF(pUtf8);
-#endif
#endif
}
else
{
-#if PY_MAJOR_VERSION >= 3
char *name = PyBytes_AsString(pystr); // hmmm... is this a good idea?
-#else
- char *name = PyString_AsString(pystr);
-#endif
ret = OUString( name, strlen(name), osl_getThreadTextEncoding() );
}
return ret;
diff --git a/pyuno/source/module/uno.py b/pyuno/source/module/uno.py
index bd894a0eea4e..c4ca808feaa0 100644
--- a/pyuno/source/module/uno.py
+++ b/pyuno/source/module/uno.py
@@ -24,14 +24,6 @@ import warnings
# since on Windows sal3.dll no longer calls WSAStartup
import socket
-# Some Python 2/3 compatibility code copied from the six library
-PY2 = sys.version_info[0] == 2
-
-if PY2:
- six_string_types = basestring,
-else:
- six_string_types = str,
-
# All functions and variables starting with a underscore (_) must be
# considered private and can be changed at any time. Don't use them.
_component_context = pyuno.getComponentContext()
@@ -216,10 +208,10 @@ class Bool(object):
message = "The Bool class is deprecated. Use Python's True and False directly instead."
warnings.warn(message, DeprecationWarning)
- if isinstance(value, six_string_types) and value == "true":
+ if isinstance(value, str) and value == "true":
return True
- if isinstance(value, six_string_types) and value == "false":
+ if isinstance(value, str) and value == "false":
return False
if value:
@@ -241,10 +233,7 @@ class Char:
"""
def __init__(self, value):
- if PY2:
- assert isinstance(value, unicode), "Expected unicode object, got %s instead." % type(value)
- else:
- assert isinstance(value, str), "Expected str object, got %s instead." % type(value)
+ assert isinstance(value, str), "Expected str object, got %s instead." % type(value)
assert len(value) == 1, "Char value must have length of 1."
@@ -254,7 +243,7 @@ class Char:
return "<Char instance %s>" % (self.value,)
def __eq__(self, that):
- if isinstance(that, six_string_types):
+ if isinstance(that, str):
if len(that) > 1:
return False
@@ -427,8 +416,7 @@ def _uno_import(name, *optargs, **kwargs):
uno_import_exc = ImportError("%s (or '%s.%s' is unknown)" %
(py_import_exc, name, class_name))
- if sys.version_info[0] >= 3:
- uno_import_exc = uno_import_exc.with_traceback(py_import_exc.__traceback__)
+ uno_import_exc = uno_import_exc.with_traceback(py_import_exc.__traceback__)
uno_import_exc._uno_import_failed = True
raise uno_import_exc
diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py
index e41f44d965bd..69b3b3ae4c97 100644
--- a/scripting/source/pyprov/mailmerge.py
+++ b/scripting/source/pyprov/mailmerge.py
@@ -11,8 +11,6 @@
# <value>true</value>
# </prop>
-from __future__ import print_function
-
import unohelper
import uno
import re
@@ -127,9 +125,6 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword()
if user != '':
- if sys.version_info < (3,0): # fdo#59249 i#105669 Python 2 needs "ascii"
- user = user.encode('ascii')
- password = password.encode('ascii')
if dbg:
print("Logging in, username of: " + user, file=dbgout)
self.server.login(user, password)
@@ -198,13 +193,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
except:
#it's a bytesequence, get raw bytes
textbody = textbody.value
- if sys.version_info >= (3,0):
- textbody = textbody.decode('utf-8')
- c = Charset('utf-8')
- c.body_encoding = QP
- textmsg.set_payload(textbody, c)
- else:
- textmsg.set_payload(textbody)
+ textbody = textbody.decode('utf-8')
+ c = Charset('utf-8')
+ c.body_encoding = QP
+ textmsg.set_payload(textbody, c)
break
@@ -326,9 +318,6 @@ class PyMailIMAPService(unohelper.Base, XMailService):
user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword()
if user != '':
- if sys.version_info < (3,0): # fdo#59249 i#105669 Python 2 needs "ascii"
- user = user.encode('ascii')
- password = password.encode('ascii')
if dbg:
print("Logging in, username of: " + user, file=dbgout)
self.server.login(user, password)
@@ -404,9 +393,6 @@ class PyMailPOP3Service(unohelper.Base, XMailService):
user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword()
- if sys.version_info < (3,0): # fdo#59249 i#105669 Python 2 needs "ascii"
- user = user.encode('ascii')
- password = password.encode('ascii')
if dbg:
print("Logging in, username of: " + user, file=dbgout)
self.server.user(user)
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py
index 82973266a2b0..5e14a863e8b8 100644
--- a/scripting/source/pyprov/pythonscript.py
+++ b/scripting/source/pyprov/pythonscript.py
@@ -27,12 +27,6 @@ import ast
import platform
from com.sun.star.uri.RelativeUriExcessParentSegments import RETAIN
-try:
- unicode
-except NameError:
- # Python 3 compatibility
- unicode = str
-
class LogLevel:
NONE = 0 # production level
ERROR = 1 # for script developers
@@ -967,7 +961,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC
inv = None
storageType = ""
- if isinstance(args[0],unicode ):
+ if isinstance(args[0], str):
storageType = args[0]
if storageType.startswith( "vnd.sun.star.tdoc" ):
doc = getModelFromDocUrl(ctx, storageType)
diff --git a/solenv/bin/version.py b/solenv/bin/version.py
index 18c04414178d..2ed1b5b83487 100755
--- a/solenv/bin/version.py
+++ b/solenv/bin/version.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-from __future__ import print_function
from optparse import OptionParser
import os.path
import re
diff --git a/solenv/gbuild/gen-autoinstall.py b/solenv/gbuild/gen-autoinstall.py
index 2feb1a92f406..44f4ecd7ffd1 100644
--- a/solenv/gbuild/gen-autoinstall.py
+++ b/solenv/gbuild/gen-autoinstall.py
@@ -9,8 +9,6 @@
# generate AutoInstall files from gbuild data for further scp2 processing
-from __future__ import print_function
-
import sys
module = sys.argv[1]
diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py
index f4818bdcfdde..8b421e167c0c 100644
--- a/unotest/source/python/org/libreoffice/unotest.py
+++ b/unotest/source/python/org/libreoffice/unotest.py
@@ -7,8 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
-
import pathlib
import subprocess
import time
diff --git a/wizards/source/access2base/access2base.py b/wizards/source/access2base/access2base.py
index af14a880cb3d..1c9c414771f8 100644
--- a/wizards/source/access2base/access2base.py
+++ b/wizards/source/access2base/access2base.py
@@ -36,8 +36,6 @@ Specific documentation about Access2Base and Python:
http://www.access2base.com/access2base.html#%5B%5BAccess2Base%20and%20Python%5D%5D
"""
-from __future__ import unicode_literals
-
import uno
XSCRIPTCONTEXT = uno
diff --git a/writerfilter/source/ooxml/factory_ns.py b/writerfilter/source/ooxml/factory_ns.py
index 17ae4e756288..1d9924e239c2 100644
--- a/writerfilter/source/ooxml/factory_ns.py
+++ b/writerfilter/source/ooxml/factory_ns.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
from xml.dom import minidom
import sys
diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py
index 41b42929563a..4fdbfda2ee4b 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
from xml.dom import minidom
import sys
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 41fa714678c7..35fdadfd3a9d 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
from xml.dom import minidom
import sys
diff --git a/writerfilter/source/ooxml/factoryinc.py b/writerfilter/source/ooxml/factoryinc.py
index e4300b2b3159..ec07f7fda1ce 100644
--- a/writerfilter/source/ooxml/factoryinc.py
+++ b/writerfilter/source/ooxml/factoryinc.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
from xml.dom import minidom
import sys
diff --git a/writerfilter/source/ooxml/modelpreprocess.py b/writerfilter/source/ooxml/modelpreprocess.py
index f81496094d47..d6ef4c175430 100644
--- a/writerfilter/source/ooxml/modelpreprocess.py
+++ b/writerfilter/source/ooxml/modelpreprocess.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
from xml.dom import minidom
import sys
diff --git a/writerfilter/source/ooxml/qnametostr.py b/writerfilter/source/ooxml/qnametostr.py
index c7fdcc1180da..e09a98570111 100644
--- a/writerfilter/source/ooxml/qnametostr.py
+++ b/writerfilter/source/ooxml/qnametostr.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
import xml.sax
import sys
diff --git a/writerfilter/source/ooxml/resourceids.py b/writerfilter/source/ooxml/resourceids.py
index c66a3367b5e0..70325c9d376b 100644
--- a/writerfilter/source/ooxml/resourceids.py
+++ b/writerfilter/source/ooxml/resourceids.py
@@ -7,7 +7,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from __future__ import print_function
import xml.sax
import sys