`d1 + d2` is semantically identical to `d3 = d1.copy(); d3.update(d2); d3`, and `d1 += d2` is semantically identical to `d1.update(d2)`. Isn't that sweet?
This whole patch adds 3 new objects with docstrings: dict.__add__, dict.__radd__, dict.__iadd__. On some builds, this puts us over the threshold, so bump the count!
Replaces two places where a failed PyDict_Update call returns NotImplemented instead of raising the error.
This brings this reference implementation in line with PEP 584's spec. Separately, allows RHS of += to be any valid arg to dict.update.
brandtbucher
changed the title
bpo-36144: Dictionary addition.
bpo-36144: Dictionary Addition/Subtraction (PEP 584)
This fixes issues where iteration errors could be swallowed, and also stops a possible reference leak.
This also implements the complex keys/__iter__ dance that update uses, as an example of compatibility with dict.update.
This is pretty much copied-and-pasted from UserDict, but it's better than what we had before. They may need some tweaking.