The following code will result in a TypeError:
invalid_values = MultiDict([('a', 'x'), ('b', ''), ('d', None)])
print(invalid_values.get('a', type=int)) # None
print(invalid_values.get('b', type=int)) # None
print(invalid_values.get('c', type=int)) # None
print(invalid_values.get('d', type=int)) # TypeError
I think the expected behavior would be to return None as all other error cases do.
This happens because the following code only checks for ValueError and not other errors like TypeError:
|
try: |
|
rv = type(rv) |
|
except ValueError: |
|
rv = default |
The following code will result in a
TypeError:I think the expected behavior would be to return
Noneas all other error cases do.This happens because the following code only checks for
ValueErrorand not other errors likeTypeError:werkzeug/src/werkzeug/datastructures/structures.py
Lines 81 to 84 in d3dd65a