Kaydet (Commit) 6b7a7d24 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Backport 1.60 and 1.62:

Patch #586999: Fix multiline string in sendmail example.

smptlib did not handle empty addresses.
The problem was that it expected rfc822.parseaddr() to return None
upon a parse failure.  The actual, documented return value for a
parse failure is (None, None).
Closes SF bug 602029.
üst 5c6ab4a2
...@@ -166,14 +166,14 @@ def quoteaddr(addr): ...@@ -166,14 +166,14 @@ def quoteaddr(addr):
Should be able to handle anything rfc822.parseaddr can handle. Should be able to handle anything rfc822.parseaddr can handle.
""" """
m=None m = (None, None)
try: try:
m=rfc822.parseaddr(addr)[1] m=rfc822.parseaddr(addr)[1]
except AttributeError: except AttributeError:
pass pass
if not m: if m == (None, None): # Indicates parse failure or AttributeError
#something weird here.. punt -ddm #something weird here.. punt -ddm
return addr return "<%s>" % addr
else: else:
return "<%s>" % m return "<%s>" % m
...@@ -604,7 +604,7 @@ class SMTP: ...@@ -604,7 +604,7 @@ class SMTP:
>>> import smtplib >>> import smtplib
>>> s=smtplib.SMTP("localhost") >>> s=smtplib.SMTP("localhost")
>>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"] >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
>>> msg = ''' >>> msg = '''\\
... From: Me@my.org ... From: Me@my.org
... Subject: testin'... ... Subject: testin'...
... ...
......
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