summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 0b2a586..baed781 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -541,8 +541,9 @@ class SMTP:
def encode_cram_md5(challenge, user, password):
challenge = base64.decodestring(challenge)
- response = user + " " + hmac.HMAC(password, challenge).hexdigest()
- return encode_base64(response)
+ response = user + " " + hmac.HMAC(password.encode('ascii'),
+ challenge).hexdigest()
+ return encode_base64(response.encode('ascii'), eol='')
def encode_plain(user, password):
s = "\0%s\0%s" % (user, password)
@@ -584,10 +585,10 @@ class SMTP:
AUTH_PLAIN + " " + encode_plain(user, password))
elif authmethod == AUTH_LOGIN:
(code, resp) = self.docmd("AUTH",
- "%s %s" % (AUTH_LOGIN, encode_base64(user)))
+ "%s %s" % (AUTH_LOGIN, encode_base64(user.encode('ascii'), eol='')))
if code != 334:
raise SMTPAuthenticationError(code, resp)
- (code, resp) = self.docmd(encode_base64(password))
+ (code, resp) = self.docmd(encode_base64(password.encode('ascii'), eol=''))
elif authmethod is None:
raise SMTPException("No suitable authentication method found.")
if code not in (235, 503):