From 9d8af3def412caa7a3242cf3a36c4371d4d3a2ee Mon Sep 17 00:00:00 2001 From: Carl Lange Date: Thu, 22 Feb 2018 15:52:11 +0000 Subject: [PATCH] Don't set a default argument as a mutable type When you run this a second time, `headers` will be the value they were last time you ran it. That seems bad. http://docs.python-guide.org/en/latest/writing/gotchas/ --- ckan/lib/mailer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ckan/lib/mailer.py b/ckan/lib/mailer.py index d40a0d5b5e9..60466c3c18c 100644 --- a/ckan/lib/mailer.py +++ b/ckan/lib/mailer.py @@ -28,7 +28,11 @@ class MailerException(Exception): def _mail_recipient(recipient_name, recipient_email, sender_name, sender_url, subject, - body, headers={}): + body, headers=None): + + if not headers: + headers = {} + mail_from = config.get('smtp.mail_from') msg = MIMEText(body.encode('utf-8'), 'plain', 'utf-8') for k, v in headers.items():