Skip to content

TypeConversionDict should not return default for KeyError during conversion #1102

@davidism

Description

@davidism

From #1078. If the conversion function raises a KeyError, that should be propagated instead of returning the default.

switch = {'a': 1}
data = TypeConversionDict(good='a', bad='b')
out = data.get('good', 'default', lambda v: switch[v])
assert out == 1
out = data.get('bad', 'default', lambda v: switch[v])
assert out != 'default' # shouldn't get here, should propagate KeyError from converter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions