One function
Container in construct/construct
The author described this change as “Container implemented unequality and wrong type, tests updated.”. It counts as a record because the check below fails on the code as it stood at 0f7cc064a and passes on d8917e72d, with nothing else changed between the two runs.
Projectconstruct/construct
Fix saved2016-09-06
Sharing licenceMIT · LICENSE
Change size+5 −0
What the code was meant to do, written into the code itself as a docstring
Generic ordered dictionary that allows both key and attribute access. Containers are dictionaries, translating attribute access into key access, and preserving key order. Also they use call method to add keys, because **kw does not preserve order. Structs parse return containers, becuase their fields have order. Example:: Container([("name","anonymous"),("age",21)]) Container(name="anonymous")(age=21) # This is NOT correct because keyword arguments order is not preserved. Container(name="anonymous",age=21) Container(container2tocopy)
The change
| 117 | 117 | __iter__ = iterkeys | |
| 118 | 118 | ||
| 119 | 119 | def __eq__(self, other, skiporder=False): | |
| 120 | + | if not isinstance(other, dict): | |
| 121 | + | return False | |
| 120 | 122 | if len(self) != len(other): | |
| 121 | 123 | return False | |
| 122 | 124 | if skiporder: | |
| ⋯ | |||
| 128 | 130 | if k != k2 or v != v2: | |
| 129 | 131 | return False | |
| 130 | 132 | return True | |
| 133 | + | ||
| 134 | + | def __ne__(self, other, skiporder=False): | |
| 135 | + | return not self.__eq__(other, skiporder) | |
| 131 | 136 | ||
| 132 | 137 | def _search(self, name, search_all): | |
| 133 | 138 | items = [] | |
The check that tells the two apart
fail→pass·tests/lib/test_container.py::TestContainer::test_ne_wrong_order
Check file tests/lib/test_container.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 it0f7cc064a9292bba4e1445b4f9be3e89185cba65
Broken version dated2016-09-06
Moduleconstruct.lib.container
Units changedContainer
Fingerprintbdd66dda7ab61c74
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 construct/construct
- 2022-09-18Lazy
- 2018-05-05Fix issue #709: Hex() might not always work.
- 2018-04-02VarInt
- 2018-03-03TransformData
- 2017-10-08FIX: Left-shift operator (#406)
- 2017-08-29Switch