diff --git a/Lib/smtplib.py b/Lib/smtplib.py --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -159,30 +159,10 @@ try: import ssl + _have_ssl = True except ImportError: _have_ssl = False -else: - class SSLFakeFile: - """A fake file like object that really wraps a SSLObject. - It only supports what is needed in smtplib. - """ - def __init__(self, sslobj): - self.sslobj = sslobj - - def readline(self): - str = "" - chr = None - while chr != "\n": - chr = self.sslobj.read(1) - if not chr: break - str += chr - return str - - def close(self): - pass - - _have_ssl = True class SMTP: """This class manages a connection to an SMTP or ESMTP server. @@ -753,9 +733,7 @@ def _get_socket(self, host, port, timeout): if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) sock = socket.create_connection((host, port), timeout) - sock = ssl.wrap_socket(sock, self.keyfile, self.certfile) - self.file = sock.makefile('rb') - return sock + return ssl.wrap_socket(sock, self.keyfile, self.certfile) __all__.append("SMTP_SSL")