Amaury Forgeot d’Arc asked an interesting question:
And what about this?
>>> x.update(self=5)
https://bugs.python.org/issue9137#msg109093
Should self be a positional-only parameter? 
I was curious to reproduce the bug. You can reintroduced it in the master branch using the change below.
update() fails with self and other arguments:
$ ./python
Python 3.8.0a3+ (heads/run_main-dirty:0be720f87d, Mar 29 2019, 14:50:44)
>>> import decimal
>>> import collections.abc
>>> traps = decimal.Context().traps
>>> isinstance(traps, collections.abc.MutableMapping)
True
>>> traps.update(other=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vstinner/prog/python/master/Lib/_collections_abc.py", line 837, in update
for key, value in other:
TypeError: 'int' object is not iterable
>>> traps.update(self=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: update() got multiple values for argument 'self'
Patch to introduce the MutableMapping.update() bug:
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index c363987970..aef6352ff0 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -821,30 +821,21 @@ class MutableMapping(Mapping):
except KeyError:
pass
- def update(*args, **kwds):
+ def update(self, other=(), **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
- if not args:
- raise TypeError("descriptor 'update' of 'MutableMapping' object "
- "needs an argument")
- self, *args = args
- if len(args) > 1:
- raise TypeError('update expected at most 1 arguments, got %d' %
- len(args))
- if args:
- other = args[0]
- if isinstance(other, Mapping):
- for key in other:
- self[key] = other[key]
- elif hasattr(other, "keys"):
- for key in other.keys():
- self[key] = other[key]
- else:
- for key, value in other:
- self[key] = value
+ if isinstance(other, Mapping):
+ for key in other:
+ self[key] = other[key]
+ elif hasattr(other, "keys"):
+ for key in other.keys():
+ self[key] = other[key]
+ else:
+ for key, value in other:
+ self[key] = value
for key, value in kwds.items():
self[key] = value