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.

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

117117 __iter__ = iterkeys
118118
119119 def __eq__(self, other, skiporder=False):
120+ if not isinstance(other, dict):
121+ return False
120122 if len(self) != len(other):
121123 return False
122124 if skiporder:
128130 if k != k2 or v != v2:
129131 return False
130132 return True
133+
134+ def __ne__(self, other, skiporder=False):
135+ return not self.__eq__(other, skiporder)
131136
132137 def _search(self, name, search_all):
133138 items = []

The check that tells the two apart

failpass·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