One function

OneToOne in mahmoud/boltons

The author described this change as fix OneToOne.update behavior with empty iterables. It counts as a record because the check below fails on the code as it stood at 985df86bb and passes on 6cac49ce4, with nothing else changed between the two runs.

Fix saved2023-11-02
Sharing licenceBSD-2-Clause · LICENSE
Change size+1 0

What the code was meant to do, written into the code itself as a docstring

Implements a one-to-one mapping dictionary. In addition to inheriting from and behaving exactly like the builtin :class:`dict`, all values are automatically added as keys on a reverse mapping, available as the `inv` attribute. This arrangement keeps key and value namespaces distinct. Basic operations are intuitive: Overwrites happens in both directions: For a very similar project, with even more one-to-one functionality, check out `bidict <https://github.com/jab/bidict>`_.

The change

121121 return self[key]
122122
123123 def update(self, dict_or_iterable, **kw):
124+ keys_vals = []
124125 if isinstance(dict_or_iterable, dict):
125126 for val in dict_or_iterable.values():
126127 hash(val)

The check that tells the two apart

failpass·tests/test_dictutils.py::test_one_to_one

Check file tests/test_dictutils.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it985df86bbf511b244ce6acf7a9c3b8a0d09d0fb3
Broken version dated2023-11-01
Moduleboltons.dictutils
Units changedOneToOne
Fingerprintc77702065b99dcf9
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in mahmoud/boltons