Workaround for the mystical is-str is-bytes bug

This commit is contained in:
László Károlyi 2015-05-11 12:31:46 +02:00
parent 48bf823f85
commit 8e03f4e3fe
1 changed files with 5 additions and 3 deletions

View File

@ -32,10 +32,12 @@ def remove_spam_flag(subject):
parsed_subject = decode_header(subject)
result = tuple()
for item in parsed_subject:
# Mystical, sometimes it's bytes, sometimes str, handle that
item_zero = item[0]
if type(item_zero) is bytes:
item_zero = item_zero.decode('utf-8')
result += (
# item[0].replace('*****SPAM***** ', ''),
item[0].decode(
'utf-8').replace('*****SPAM***** ', ''),
item_zero.replace('*****SPAM***** ', ''),
item[1]), # Note it's a tuple
return result