On Jun 19, 10:16 am, Wells Oliver <we...@submute.net> wrote:
> Writing a class which essentially spiders a site and saves the files
> locally. On a URLError exception, it sleeps for a second and tries again (on
> 404 it just moves on). The relevant bit of code, including the offending
> method:
>
> [snip]
>
> But what I am seeing is that after a retry (on catching a URLError
> exception), I see bunches of "UnboundLocalError: local variable 'handler'
> referenced before assignment" errors on line 38, which is the
> "file.write(handler.read())" line..
>
> What gives?

'Handler' is only assigned in the try statement, so if you error into
your exception clause, nothing will have been bound to the name
'handler', causing the exception you're seeing.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to