Skip to content

MultiDict does not handle None values #2842

@Sympatron

Description

@Sympatron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions