]> granicus.if.org Git - python/commitdiff
smptlib did not handle empty addresses.
authorRaymond Hettinger <python@rcn.com>
Thu, 5 Sep 2002 01:14:07 +0000 (01:14 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 5 Sep 2002 01:14:07 +0000 (01:14 +0000)
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 a6f113cd7c692279c35368f6768879b5069ea970..066fd9c8e2d52f8d44b2da7c536e2c63957dc40f 100755 (executable)
@@ -168,14 +168,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