diff options
| author | R. David Murray <rdmurray@bitdance.com> | 2009-05-28 18:19:00 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2009-05-28 18:19:00 (GMT) |
| commit | fb12391c44d9491e2d1635eb5f82af3b0da0ec29 (patch) | |
| tree | f27aae38f6956cc7e521a1743e1d9b76f17216ee /Lib/smtplib.py | |
| parent | e2cedaadb572c1bd58553ef5e27af0efc890d9b8 (diff) | |
| download | cpython-fb12391c44d9491e2d1635eb5f82af3b0da0ec29.zip cpython-fb12391c44d9491e2d1635eb5f82af3b0da0ec29.tar.gz cpython-fb12391c44d9491e2d1635eb5f82af3b0da0ec29.tar.bz2 | |
Finish issue 5259 by adding tests and fixes for the 'login'
and 'cram-md5' auth methods.
Diffstat (limited to 'Lib/smtplib.py')
| -rwxr-xr-x | Lib/smtplib.py | 9 |
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): |
