Skip to content

Commit

Permalink
Fix parse_list() to handle Address objects with unicode properly also.
Browse files Browse the repository at this point in the history
  • Loading branch information
spang committed Jan 13, 2015
1 parent ede112b commit 1dea030
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion flanker/addresslib/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@
from flanker.mime.message.headers.encodedword import mime_to_unicode
from urlparse import urlparse


def _normalize_address_list(address_list):
parts = []

for addr in address_list:
if isinstance(addr, Address):
parts.append(unicode(addr))
if isinstance(addr, basestring):
parts.append(addr)

return parts


@metrics_wrapper()
def parse(address, addr_spec_only=False, metrics=False):
"""
Expand Down Expand Up @@ -130,7 +143,7 @@ def parse_list(address_list, strict=False, as_tuple=False, metrics=False):

# if we have a list, transform it into a string first
if isinstance(address_list, list):
address_list = ', '.join(address_list)
address_list = ', '.join(_normalize_address_list(address_list))

# parse
try:
Expand Down

0 comments on commit 1dea030

Please sign in to comment.