summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-02-23 12:27:17 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-02-23 12:27:17 (GMT)
commit1660933d23ed99393c2ea9bbe0204318936e3bbc (patch)
tree767766b54f607b0fed90e4c386f5578246af5d89 /Lib
parentfc2d01032fa4eb2d5563c2619811d05567faf528 (diff)
downloadcpython-1660933d23ed99393c2ea9bbe0204318936e3bbc.zip
cpython-1660933d23ed99393c2ea9bbe0204318936e3bbc.tar.gz
cpython-1660933d23ed99393c2ea9bbe0204318936e3bbc.tar.bz2
Issue 1776581. Minor corrections to smtplib, and two small tests.
Thanks Alan McIntyre.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/smtplib.py4
-rw-r--r--Lib/test/test_smtplib.py5
2 files changed, 5 insertions, 4 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index bb9c239..75093ae 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -298,7 +298,7 @@ class SMTP:
def send(self, str):
"""Send `str' to the server."""
if self.debuglevel > 0: print>>stderr, 'send:', repr(str)
- if self.sock:
+ if hasattr(self, 'sock') and self.sock:
try:
self.sock.sendall(str)
except socket.error:
@@ -486,7 +486,7 @@ class SMTP:
vrfy=verify
def expn(self, address):
- """SMTP 'verify' command -- checks for address validity."""
+ """SMTP 'expn' command -- expands a mailing list."""
self.putcmd("expn", quoteaddr(address))
return self.getreply()
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index e2b9b06..933523b 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -82,8 +82,9 @@ class GeneralTests(TestCase):
# to reference the nonexistent 'sock' attribute of the SMTP object
# causes an AttributeError)
smtp = smtplib.SMTP()
- self.assertRaises(AttributeError, smtp.ehlo)
- self.assertRaises(AttributeError, smtp.send, 'test msg')
+ self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo)
+ self.assertRaises(smtplib.SMTPServerDisconnected,
+ smtp.send, 'test msg')
def testLocalHostName(self):
# check that supplied local_hostname is used