Index: Lib/_abcoll.py =================================================================== --- Lib/_abcoll.py (revision 82435) +++ Lib/_abcoll.py (working copy) @@ -480,16 +480,22 @@ except KeyError: pass - def update(self, other=(), **kwds): - 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 + def update(self, *args, **kwds): + if args: + if len(args) > 1: + raise TypeError("update expected at most 1 " + "positional argument") + 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 + for key, value in kwds.items(): self[key] = value Index: Lib/test/test_collections.py =================================================================== --- Lib/test/test_collections.py (revision 82435) +++ Lib/test/test_collections.py (working copy) @@ -758,6 +758,16 @@ od.update([('a', 1), ('b', 2), ('c', 9), ('d', 4)], c=3, e=5) self.assertEqual(list(od.items()), pairs) # mixed input + # Issue 9137: A named argument called 'other' shouldn't be + # treated specially. + od = OrderedDict() + od.update(other={}) + self.assertEqual(list(od.items()), [('other', {})]) + od = OrderedDict() + od.update(red=5, blue=6, other=7) + self.assertEqual(sorted(list(od.items())), + [('blue', 6), ('other', 7), ('red', 5)]) + # Make sure that direct calls to update do not clear previous contents # add that updates items are not moved to the end d = OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 44), ('e', 55)])