bug fix.

fix a bug that would generate UnboundLocal Exception, thanks everyone
in
http://stackoverflow.com/questions/21927065/catch-exception-gets-unbound
localerror.