Kaydet (Commit) 1a5b3d8e authored tarafından Michael Stahl's avatar Michael Stahl

fdo#59249: mailmerge.py: adapt to changes in smtplib:

Apparently the login() method in Python 3.3 expects str arguments for
user and password, since it calls encode on them, but for Python 2.6 the
"encode" calls were explicitly added in the caller since login() does
not encode itself; add an ugly version check for that.

Change-Id: Iebfce44073a837e9cb845855ba448d5b6a2ebd11
üst b08dc0b7
...@@ -99,9 +99,12 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): ...@@ -99,9 +99,12 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
self.server.starttls() self.server.starttls()
self.server.ehlo() self.server.ehlo()
user = xAuthenticator.getUserName().encode('ascii') user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword().encode('ascii') password = xAuthenticator.getPassword()
if user != b'': if user != '':
if sys.version < '3': # fdo#59249 i#105669 Python 2 needs "ascii"
user = user.encode('ascii')
password = password.encode('ascii')
if dbg: if dbg:
print("Logging in, username of", user, file=dbgout) print("Logging in, username of", user, file=dbgout)
self.server.login(user, password) self.server.login(user, password)
...@@ -279,9 +282,12 @@ class PyMailIMAPService(unohelper.Base, XMailService): ...@@ -279,9 +282,12 @@ class PyMailIMAPService(unohelper.Base, XMailService):
self.server = imaplib.IMAP4(server, port) self.server = imaplib.IMAP4(server, port)
print("AFTER", file=dbgout) print("AFTER", file=dbgout)
user = xAuthenticator.getUserName().encode('ascii') user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword().encode('ascii') password = xAuthenticator.getPassword()
if user != b'': if user != '':
if sys.version < '3': # fdo#59249 i#105669 Python 2 needs "ascii"
user = user.encode('ascii')
password = password.encode('ascii')
if dbg: if dbg:
print("Logging in, username of" + user, file=dbgout) print("Logging in, username of" + user, file=dbgout)
self.server.login(user, password) self.server.login(user, password)
...@@ -348,8 +354,11 @@ class PyMailPOP3Service(unohelper.Base, XMailService): ...@@ -348,8 +354,11 @@ class PyMailPOP3Service(unohelper.Base, XMailService):
self.server = poplib.POP3(server, port) self.server = poplib.POP3(server, port)
print("AFTER", file=dbgout) print("AFTER", file=dbgout)
user = xAuthenticator.getUserName().encode('ascii') user = xAuthenticator.getUserName()
password = xAuthenticator.getPassword().encode('ascii') 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: if dbg:
print("Logging in, username of" + user, file=dbgout) print("Logging in, username of" + user, file=dbgout)
self.server.user(user) self.server.user(user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment