diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2019-06-01 08:00:15 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-01 08:00:15 (GMT) |
| commit | 2085bd0877e17ad4d98a4586d5eabb6faecbb190 (patch) | |
| tree | c25b20d33ebf4d64a28abb8591f4ff7acf90614c /Lib/_collections_abc.py | |
| parent | 4a686504eb2bbf69adf78077458508a7ba131667 (diff) | |
| download | cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.zip cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.gz cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.bz2 | |
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
Diffstat (limited to 'Lib/_collections_abc.py')
| -rw-r--r-- | Lib/_collections_abc.py | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py index c363987..2b2ddba 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 |
