Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f655328

Browse files
committed
parseaddr(): Fixed in the same way that Message.getaddrlist() was
fixed (re: SF bug #555035). Include a unittest.
1 parent 12424bc commit f655328

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Lib/rfc822.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def quote(str):
495495
def parseaddr(address):
496496
"""Parse an address into a (realname, mailaddr) tuple."""
497497
a = AddressList(address)
498-
list = a.getaddrlist()
498+
list = a.addresslist
499499
if not list:
500500
return (None, None)
501501
else:

Lib/test/test_rfc822.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ def test_2getaddrlist(self):
213213
addrs.sort()
214214
eq(addrs, ccs)
215215

216+
def test_parseaddr(self):
217+
eq = self.assertEqual
218+
eq(rfc822.parseaddr('<>'), ('', ''))
219+
eq(rfc822.parseaddr('[email protected]'), ('', '[email protected]'))
220+
eq(rfc822.parseaddr('[email protected] (Bea A. Person)'),
221+
('Bea A. Person', '[email protected]'))
222+
eq(rfc822.parseaddr('Cynthia Person <[email protected]>'),
223+
('Cynthia Person', '[email protected]'))
224+
216225
def test_main():
217226
test_support.run_unittest(MessageTestCase)
218227

0 commit comments

Comments
 (0)