dataflake.org

Home Documentation Software Old Stuff

UnboundLocalError: local variable 'stat' referenced before assignment (Resolved)

Request MaildropHost -- bug report -- by Jeremy Bobbio
Posted on Feb 14, 2007 12:17 pm
Subscribe

Enter your email address to receive mail on every change to this issue.

Entries (Latest first)


  Resolve by Jens Vagelpohl on Feb 14, 2007 12:35 pm
  Forgot to resolve
 

  Comment by Jens Vagelpohl on Feb 14, 2007 12:34 pm
  Thanks for the report this is now fixed on the trunk:

http://svn.dataflake.org/?view=rev&revision=1390

I'll release a new version today as well, it's been a while.


 

  Initial Request by Jeremy Bobbio on Feb 14, 2007 12:17 pm
  In some cases, the maildrop daemon can fail with the following exception:

File "/zope/instance/Products/MaildropHost/maildrop/maildrop.py", line 330, in ?
mainloop()
File "/zope/instance/Products/MaildropHost/maildrop/maildrop.py", line 154, in mainloop
mail_msg = '\n%s\t %s' % (stat, h_to)
UnboundLocalError: local variable 'stat' referenced before assignment

The fix seems actually pretty simple. When there is actually no recipients "stat" does not get initialized. At first sight, assigning it out of the "for" loop fix the issue.

--- MaildropHost/maildrop/maildrop.py.orig 2007-02-14 17:59:52.000000000 +0100 +++ MaildropHost/maildrop/maildrop.py 2007-02-14 18:00:11.000000000 +0100
@@ -143,8 +143,8 @@
stat = 'OK'
os.remove(file_path)
except smtplib.SMTPRecipientsRefused, e:
+ stat = 'FATAL: ', str(e)
for (addr, error) in e.recipients.items():
- stat = 'FATAL: ', str(e)
if str(error[0]) in FATAL_ERROR_CODES:
os.remove(file_path)
break