You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. When a validator accidentally raises a ZeroDivisionError, the is correctly raised, but when a validator accidentally raises a ValueError, an IndexError is raised instead. This makes the debugging a bit more difficult.
Here is a script to reproduce the problem:
importwtformsimportwerkzeugdefdivision_error_validator(form, field): raiseZeroDivisionErrorclassDivisionErrorForm(wtforms.Form):
foo=wtforms.StringField(validators=[division_error_validator])
defvalue_error_validator(form, field): raiseValueErrorclassValueErrorForm(wtforms.Form):
foo=wtforms.StringField(validators=[value_error_validator])
try:
DivisionErrorForm(werkzeug.ImmutableMultiDict({"bar": "baz"})).validate()
exceptZeroDivisionError:
print("ZeroDivisionError OK")
exceptExceptionasexc:
print("ZeroDivisionError KO - found %s"%type(exc))
try:
ValueErrorForm(werkzeug.ImmutableMultiDict({"bar": "baz"})).validate()
exceptValueError:
print("ValueError OK")
exceptExceptionasexc:
print("ValueError KO - found %s"%type(exc))
# prints# ZeroDivisionError OK# ValueError KO - found <type 'exceptions.IndexError'>
The text was updated successfully, but these errors were encountered:
azmeuk
changed the title
Validators do not catch ValueErrors
Validators do not raise IndexError when it catches a ValueErrors
Aug 30, 2018
azmeuk
changed the title
Validators do not raise IndexError when it catches a ValueErrors
Validators do not raise IndexError when it catches a ValueError
Aug 30, 2018
azmeuk
added a commit
to azmeuk/wtforms
that referenced
this issue
Apr 17, 2020
Hi. When a validator accidentally raises a ZeroDivisionError, the is correctly raised, but when a validator accidentally raises a ValueError, an IndexError is raised instead. This makes the debugging a bit more difficult.
Here is a script to reproduce the problem:
The text was updated successfully, but these errors were encountered: