Re: Crappy Python code of the day

2017-02-28 Thread Rick Johnson
On Wednesday, February 15, 2017 at 10:16:14 PM UTC-6, Steven D'Aprano wrote: > Oh, we know why the code is failing. We don't need help > diagnosing the UnboundLocalError exception. You're right: > there's an except pass around an assignment, so if the > assignment fails, `result` never gets set. >

Re: Crappy Python code of the day

2017-02-15 Thread Steven D'Aprano
On Thu, 16 Feb 2017 14:28:57 +1100, Chris Angelico wrote: > On Thu, Feb 16, 2017 at 1:25 PM, Steven D'Aprano > wrote: >> This has been in production for months, the writer of the code has left >> and the new maintainer has been asked to find out why it has been >> crashing with UnboundLocalError:

Re: Crappy Python code of the day

2017-02-15 Thread Chris Angelico
On Thu, Feb 16, 2017 at 1:25 PM, Steven D'Aprano wrote: > This has been in production for months, the writer of the code has left > and the new maintainer has been asked to find out why it has been > crashing with UnboundLocalError: > > > try: > result = future.result() > except re

Crappy Python code of the day

2017-02-15 Thread Steven D'Aprano
This has been in production for months, the writer of the code has left and the new maintainer has been asked to find out why it has been crashing with UnboundLocalError: try: result = future.result() except requests.exceptions.ConnectionError as e: pass resp = self.