From c4fa6efa67775a6b333a4a5aa873b5cc24a4f7bc Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Sat, 4 Apr 2020 20:01:17 +0200 Subject: 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. Change-Id: I26414ae8e9f8402c90336af82020135685694217 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91697 Tested-by: Jenkins Reviewed-by: Michael Stahl --- scripting/source/pyprov/mailmerge.py | 22 ++++------------------ scripting/source/pyprov/pythonscript.py | 8 +------- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'scripting/source') 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 @@ # true # -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) -- cgit v1.2.3