]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 1.60 and 1.62:
authorRaymond Hettinger <python@rcn.com>
Sun, 6 Oct 2002 03:37:00 +0000 (03:37 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 6 Oct 2002 03:37:00 +0000 (03:37 +0000)
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.

Lib/smtplib.py

index a5464758f3ee7648d9b49d1f6da19cd930fc6275..0ace9ad8723987beaffc0c5c6c25aea1ad9d8ef3 100755 (executable)
@@ -166,14 +166,14 @@ def quoteaddr(addr):
 
     Should be able to handle anything rfc822.parseaddr can handle.
     """
-    m=None
+    m = (None, None)
     try:
         m=rfc822.parseaddr(addr)[1]
     except AttributeError:
         pass
-    if not m:
+    if m == (None, None): # Indicates parse failure or AttributeError
         #something weird here.. punt -ddm
-        return addr
+        return "<%s>" % addr
     else:
         return "<%s>" % m
 
@@ -604,7 +604,7 @@ class SMTP:
          >>> import smtplib
          >>> s=smtplib.SMTP("localhost")
          >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
-         >>> msg = '''
+         >>> msg = '''\\
          ... From: Me@my.org
          ... Subject: testin'...
          ...