From: Barry Warsaw Date: Thu, 23 May 2002 03:21:01 +0000 (+0000) Subject: parseaddr(): Fixed in the same way that Message.getaddrlist() was X-Git-Tag: v2.3c1~5609 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f655328483b2e237cc2f71c1c308eceb2f30f6fd;p=python parseaddr(): Fixed in the same way that Message.getaddrlist() was fixed (re: SF bug #555035). Include a unittest. --- diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 826269fe1a..0ce546ced7 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -495,7 +495,7 @@ def quote(str): def parseaddr(address): """Parse an address into a (realname, mailaddr) tuple.""" a = AddressList(address) - list = a.getaddrlist() + list = a.addresslist if not list: return (None, None) else: diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index dfce7c9151..6add15b16d 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -213,6 +213,15 @@ A test message. addrs.sort() eq(addrs, ccs) + def test_parseaddr(self): + eq = self.assertEqual + eq(rfc822.parseaddr('<>'), ('', '')) + eq(rfc822.parseaddr('aperson@dom.ain'), ('', 'aperson@dom.ain')) + eq(rfc822.parseaddr('bperson@dom.ain (Bea A. Person)'), + ('Bea A. Person', 'bperson@dom.ain')) + eq(rfc822.parseaddr('Cynthia Person '), + ('Cynthia Person', 'cperson@dom.ain')) + def test_main(): test_support.run_unittest(MessageTestCase)