email: Don't assume `extra_headers` has content in get_message()
authorW. Trevor King <wking@tremily.us>
Sat, 19 Jan 2013 18:22:49 +0000 (13:22 -0500)
committerW. Trevor King <wking@tremily.us>
Wed, 23 Jan 2013 14:16:35 +0000 (09:16 -0500)
The default is None, so we should at least handle that case
gracefully.

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/email.py

index 2f6872db3d34c95e835b1714bfd3988902893310..45b105fad6f0fc298960a1169f6eca550fec2d22 100644 (file)
@@ -112,9 +112,10 @@ def get_message(sender, recipient, subject, body, content_type,
     message['From'] = _formataddr((sender_name, sender_addr))
     message['To'] = _formataddr((recipient_name, recipient_addr))
     message['Subject'] = _Header(subject, subject_encoding)
-    for key,value in extra_headers.items():
-        encoding = guess_encoding(value, encodings)
-        message[key] = _Header(value, encoding)
+    if extra_headers:
+        for key,value in extra_headers.items():
+            encoding = guess_encoding(value, encodings)
+            message[key] = _Header(value, encoding)
     return message
 
 def smtp_send(sender, recipient, message, config=None, section='DEFAULT'):