Skip to content

Commit

Permalink
Don't set a default argument as a mutable type
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
CarlQLange committed Feb 22, 2018
1 parent 88b5aa3 commit 9d8af3d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ckan/lib/mailer.py
Expand Up @@ -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():
Expand Down

0 comments on commit 9d8af3d

Please sign in to comment.