Killing Another Bug
apt.shansen at gmail.com
Fri Dec 4 21:46:38 CET 2009
On Fri, Dec 4, 2009 at 7:52 AM, Victor Subervi <victorsubervi at gmail.com>wrote:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list