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:
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
if len(x) == 2:
quality = x # Get the quality
quality = quality[2:] # Get the number (remove "q=")
quality = float(quality) # Change it to float
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" 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 ;)
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce