[Zope] Bare except clause in respect to self.DestinationURL()

Sascha Welter zopelist at betabug.ch
Sat Oct 13 15:30:05 EDT 2007


Hello Zopistas!

This pattern here is very common in many people's Zope products:

    try: u=self.DestinationURL()
    except: u=REQUEST['URL1']

It's usually in the manage_addXY() method, when all the work is done, we
test for REQUEST!=None and we want to know where to redirect to.

Is there a reason for that bare except here? Wouldn't 
except AttributeError: ... do the job just as well?

Currently I'm in the process of smoking out bare except clauses in the
Zwiki code. I've learned that bare except clauses are bad (amongst other
reasons mainly because they can swallow ConflictErrors), so I try to be
a good kid and get rid of them. This spot seems to be somewhere where a
ConflictError could happen (we're creating something), but OTOH it gets
run when creating from the ZMI, so...

It might be that in this spot it's just irrelevant and I've turned
pedantic in my hunt - or there might be a reason for this.
What do you think?

Regards,

Sascha

PS. I hope this doesn't kick off a bike shed discussion... :-)


More information about the Zope mailing list