Skip to content

ImmutableDicts should throw errors on attempted mutation #88

@presheaf

Description

@presheaf

When you attempt to e.g. insert a key in an ImmutableDict object, nothing happens - no error is thrown or anything. This means that bugs can pass undetected, and is unfortunate. For example, I was parsing an EDN file and forgot that the map within it would become immutable, treating it as a regular Python dict by attempting to insert keys, then ran into strange behavior because my insertions were being silently ignored. See below for an example:

import edn_format
d = edn_format.immutable_dict.ImmutableDict({"apple": 1, "pear": 2})
d["banana"] = 3                 # does not throw an error, just is silently ignored
print(d["banana"])              # oops, KeyError

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions