diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-04-04 20:01:17 +0200 |
---|---|---|
committer | Gabor Kelemen <gabor.kelemen.extern@allotropia.de> | 2023-11-09 20:45:02 +0100 |
commit | 61f19b858d0adfe4163b7c3bccde031bfb8cc5e8 (patch) | |
tree | 6dc659b25cab44777a88434341439d28aeffccc3 | |
parent | 4f67458ffb0e37a391a024be0d43a60855d743c4 (diff) |
pyuno,*: kill Python 2 support with fire
Python 2 support was retained for use with --enable-python=system
on RHEL7 and SLES. The time has arrived to remove it.
Some .py files that were imported from third parties are not changed to
enable easier replacement with updated versions if necessary.
solenv/gdb should continue to support Python 2.
bin/get-bugzilla-attachments-by-mimetype requires Python 2 to access
Launchpad.
Also integrate:
commit 76a29148be63cb006a7e25e312dc93acc93e071f
const fixes for python3-devel-3.7.0-1.fc29.x86_64
Change-Id: I26414ae8e9f8402c90336af82020135685694217
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91697
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
26 files changed, 26 insertions, 239 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 79e4d02b64bf..84eab4140a01 100644 --- a/configure.ac +++ b/configure.ac @@ -8129,14 +8129,13 @@ AC_SUBST(LIBXML_LIBS) AC_SUBST(XMLLINT) # ===================================================================== -# Checking for a Python interpreter with version >= 2.6. -# Build and runtime requires Python 3 compatible version (>= 2.6). +# Checking for a Python interpreter with version >= 3.3. # Optionally user can pass an option to configure, i. e. # ./configure PYTHON=/usr/bin/python # ===================================================================== if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then # This allows a lack of system python with no error, we use internal one in that case. - AM_PATH_PYTHON([2.6],, [:]) + AM_PATH_PYTHON([3.3],, [:]) # Clean PYTHON_VERSION checked below if cross-compiling PYTHON_VERSION="" if test "$PYTHON" != ":"; then @@ -8280,11 +8279,10 @@ system) #include <Python.h> int main(int argc, char **argv) { - if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6) || - (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.6 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 f501deec18d1..5d5b2976e9c0 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__(): @@ -324,7 +317,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()) @@ -1314,9 +1307,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])) @@ -1601,12 +1594,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 5fb475c2e6df..e872c2fb8976 100644 --- a/pyuno/inc/pyuno.hxx +++ b/pyuno/inc/pyuno.hxx @@ -58,12 +58,7 @@ the global interpreter lock is held */ -extern "C" LO_DLLPUBLIC_PYUNO -#if PY_MAJOR_VERSION >= 3 - PyObject* SAL_CALL PyInit_pyuno(); -#else - void SAL_CALL initpyuno(); -#endif +extern "C" LO_DLLPUBLIC_PYUNO PyObject* PyInit_pyuno(); namespace pyuno { diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py index ddb9001fc0e6..385728fd6dcf 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 >= '3': - 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 0408af0f4043..bbbc3edc1b7b 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -123,7 +123,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); @@ -138,10 +137,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 ) @@ -215,11 +210,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 69009651b5a9..fbe0ccccdf1c 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -318,14 +318,9 @@ 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; } @@ -337,14 +332,8 @@ int lcl_PySlice_GetIndicesEx( PyObject *pObject, sal_Int32 nLen, sal_Int32 *nSta { 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; @@ -1558,9 +1547,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 */ @@ -1574,22 +1560,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 98593ebcf372..322557aa46c3 100644 --- a/pyuno/source/module/pyuno_dlopenwrapper.c +++ b/pyuno/source/module/pyuno_dlopenwrapper.c @@ -75,19 +75,9 @@ static void * load(void * 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 3f87ad7a9309..4e5a55fa78d7 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 @@ -72,7 +63,6 @@ typedef long Py_hash_t; // 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) @@ -111,41 +101,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 40ed69e0191b..b41e7bc02ffa 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -850,7 +850,6 @@ struct PyMethodDef PyUNOModule_methods [] = } extern "C" -#if PY_MAJOR_VERSION >= 3 PyObject* PyInit_pyuno() { PyUNO_initType(); @@ -871,14 +870,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 8e47b6924711..39433f6517c9 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -634,41 +634,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) { @@ -680,8 +647,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con } else { -#endif /* PY_MAJOR_VERSION >= 3 */ - sal_Int64 l = (sal_Int64)PyLong_AsLong (o); + sal_Int64 l = static_cast<sal_Int64>(PyLong_AsLong (o)); if( l < 128 && l >= -128 ) { sal_Int8 b = (sal_Int8 ) l; @@ -702,9 +668,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 b09c78de1205..01e6aa34158e 100644 --- a/pyuno/source/module/pyuno_type.cxx +++ b/pyuno/source/module/pyuno_type.cxx @@ -135,7 +135,7 @@ sal_Unicode PyChar2Unicode( PyObject *obj ) "attribute value of uno.Char is not a unicode string" ); } - if( PyUnicode_GetSize( value.get() ) < 1 ) + if( PyUnicode_GetLength( value.get() ) < 1 ) { throw RuntimeException( "uno.Char contains an empty unicode string"); @@ -157,7 +157,7 @@ Any PyEnum2Enum( PyObject *obj ) } OUString strTypeName( OUString::createFromAscii( PyStr_AsString( typeName.get() ) ) ); - char *stringValue = PyStr_AsString( value.get() ); + char const *stringValue = PyStr_AsString( value.get() ); TypeDescription desc( strTypeName ); if( desc.is() ) diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx index aecca4ad2eae..7c52f98c376a 100644 --- a/pyuno/source/module/pyuno_util.cxx +++ b/pyuno/source/module/pyuno_util.cxx @@ -67,24 +67,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 *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 bccf22d0f8ac..cccd6d788d91 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() @@ -210,10 +202,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: @@ -235,10 +227,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." @@ -248,7 +237,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 @@ -418,8 +407,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 235472b2a85d..44b9261ecf99 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 @@ -124,9 +122,6 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): user = xAuthenticator.getUserName() password = xAuthenticator.getPassword() if user != '': - if sys.version < '3': # 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) @@ -195,20 +190,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): except: #it's a bytesequence, get raw bytes textbody = textbody.value - if sys.version >= '3': - if sys.version_info.minor < 3 or (sys.version_info.minor == 3 and sys.version_info.micro <= 1): - #http://stackoverflow.com/questions/9403265/how-do-i-use-python-3-2-email-module-to-send-unicode-messages-encoded-in-utf-8-w - #see http://bugs.python.org/16564, etc. basically it now *seems* to be all ok - #in python 3.3.2 onwards, but a little busted in 3.3.0 - - textbody = textbody.decode('iso8859-1') - else: - 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 @@ -330,9 +315,6 @@ class PyMailIMAPService(unohelper.Base, XMailService): user = xAuthenticator.getUserName() password = xAuthenticator.getPassword() if user != '': - if sys.version < '3': # 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) @@ -408,9 +390,6 @@ class PyMailPOP3Service(unohelper.Base, XMailService): user = xAuthenticator.getUserName() password = xAuthenticator.getPassword() - if sys.version < '3': # 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 c46565949665..51d2ebac9f4d 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 @@ -962,7 +956,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 53690bf439f5..4aad65d1c11b 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 13b00845bb36..96b9270485ff 100644 --- a/unotest/source/python/org/libreoffice/unotest.py +++ b/unotest/source/python/org/libreoffice/unotest.py @@ -7,8 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from __future__ import print_function - +import pathlib import subprocess import time import uuid diff --git a/writerfilter/source/ooxml/factory_ns.py b/writerfilter/source/ooxml/factory_ns.py index 54afd1e1d568..01a3a1394562 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 1e172c589ea1..fa9e8991897e 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 80e0c84c691c..ac10de4d27ee 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 7b6f8de0f9f3..c6aca847df8a 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 087f00c83f86..12df2afc3acd 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 |