One function

Dict in mewwts/addict

The author described this change as Should fix issue #28 with the constructor not working well. It counts as a record because the check below fails on the code as it stood at 1ae299183 and passes on bc5a78e62, with nothing else changed between the two runs.

Fix saved2014-12-14
Sharing licenceMIT · LICENSE
Change size+10 4

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

Dict is a subclass of dict, which allows you to get AND SET(!!) items in the dict using the attribute syntax! When you previously had to write: my_dict = {'a': {'b': {'c': [1, 2, 3]}}} you can now do the same simply by: my_Dict = Dict() my_Dict.a.b.c = [1, 2, 3] Or for instance, if you'd like to add some additional stuff, where you'd with the normal dict would write my_dict['a']['b']['d'] = [4, 5, 6], you may now do the AWESOME my_Dict.a.b.d = [4, 5, 6] instead. But hey, you can always use the same syntax as a regular dict, however, this will not raise TypeErrors or AtrributeErrors at any time while you try to get an item. A lot like a defaultdict.

The change

3434 """
3535 for arg in args:
3636 if not arg:
37- pass
37+ continue
3838 elif isinstance(arg, dict):
3939 for key, val in arg.items():
4040 self[key] = val
41- else:
41+ elif isinstance(arg, list) or isgenerator(arg):
42+ for key, val in arg:
43+ self[key] = val
44+ elif isinstance(arg, tuple):
4245 self[arg[0]] = arg[1]
46+ else:
47+ raise TypeError("Dict does not understand "
48+ "{0} types".format(type(arg)))
4349
4450 for key, val in kwargs.items():
4551 self[key] = val
5056
5157 """
5258 if hasattr(Dict, name):
53- raise AttributeError("'Dict' object attribute"
54- " '{0}' is read-only".format(name))
59+ raise AttributeError("'Dict' object attribute "
60+ "'{0}' is read-only".format(name))
5561 else:
5662 self[name] = value
5763

The check that tells the two apart

failpass·test_addict.py::Tests::test_init_raises

Check file test_addict.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 it1ae29918391857bac904361ad6cf7b9a9c568632
Broken version dated2014-12-14
Moduleaddict.addict
Units changedDict
Fingerprintc6ca7d722d4a1820
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 mewwts/addict