Killing Another Bug
Victor Subervi
victorsubervi at gmail.com
Fri Dec 4 16:46:46 EST 2009
On Fri, Dec 4, 2009 at 3:46 PM, Stephen Hansen <apt.shansen at gmail.com>wrote:
>
> On Fri, Dec 4, 2009 at 7:52 AM, Victor Subervi <victorsubervi at gmail.com>wrote:
>
>> except:
>>
>
>
>> except:
>> pass
>>
>
> If you want any hope of fixing the bug, remove both of these. Really -- do
> not use bare excepts.
>
> In the first one, it looks like you're expecting sometimes there to be an
> exception: that's okay. If you think an operation will produce one, its okay
> to catch it if you know how to handle it. But do NOT use bare excepts.
> Catch the actual exception you are expecting-- a KeyError maybe? ValueError?
> I don't know, can't tell without knowing what "fn" does.
>
> In the second-- that bare except with a pass is doing absolutely nothing
> but _destroying_ any chance you have of finding out what the bug IS and
> fixing the bug. Remove that entire try/except: pass statement. Really. You
> absolutely have to do it. The only reason you have not already found and
> fixed this bug is that you have done this-- you can't do this and then ask
> us to find the bug for you.
>
> Bare excepts are there for a reason, and there are times to use them. But
> those are the exception and not the rule; and the time to use a except: pass
> construct is NOT when you're trying to fix a bug.
>
Right <:-}
I changed the "pass" to "raise" and discovered an error I "worked around"
while I was trying to solve another problem...then subsequently forgot about
this. You know, I'm really a poet and singer/songwriter, unfortunately that
doesn't pay the bills. When will I ever learn to think in my left hemisphere
like a programmer :-}
Thanks,
V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091204/37e6c822/attachment-0001.html>
More information about the Python-list
mailing list