Leonardo Rochael Almeida wrote:
In general, a generic except is evil.On Mon, 2003-02-10 at 10:27, Romain Slootmaekers wrote:Romain Slootmaekers wrote:
Hi,
below the original post:
it is a bug in Products/Localizer/Accept.py
here's the code to fix it:
#--- code fix starting from line 102 ---
# Get the quality
try:
if len(x) == 2:
quality = x[1] # Get the quality
quality =quality.strip()
quality = quality[2:] # Get the number (remove "q=")
quality = float(quality) # Change it to float
else:
quality = 1.0
except:
quality=1.0
#--- end of code fix ---
I added a strip() and a try/except for other things that can go wrong.
Please, please, please, don't use generic "except:". They can cause ZODB corruption if they catch ConflictErrors. In the case of the code above, test for specific errors that "float(quality)" or "x[1]" can raise and catch those instead.
Here, I seriously don't see how the code inside the try/except can cause a conflict error or other serious damage.
In general, general remarks are evil ;)
Sloot.
_______________________________________________
Zope-Dev maillist - [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )