rootpy/rootpy — pull request #87 by pwaller (2012-11-23 11:30:45+00:00)
Title: Emit an error wherever the diaper pattern is used

I think that overbroad exceptions should be considered severe bugs, since
they lead to crazy debugging headaches. I speak from experience.

It's bad practice in python to catch exceptions you're not explicitly
expecting. Python's mantra "It's easier to ask forgiveness and permission"
doesn't apply to thinks you weren't intending to do.

try:
...
except:
pass

will prevent python from exiting, and silence errors you weren't aware of
anywhere upstream, making it much harder to debug programs.

The same applies with this:

try:
from mod import stuff
except ImportError:
pass

Unfortunately the above is also a bad idea, because it might catch things you
weren't expecting, such as one of `mod`'s imports failing. It is better to
have mod set another variable (`have_stuff`?) than to catch more than you
intended to.

This stuff leads to debugging nightmares, so I've put in an error message at
a few points with the text "BUG: please report this! (exception type)", so
that the correct exception type can be used.

IMHO, it's better to ask permission where it's easily possible.