diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py index e61238ff7d2..a7541c854a1 100644 --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -155,8 +155,12 @@ class SeqDict(DictMixin): raise KeyError return self.valuelist[i] def __setitem__(self, key, value): - self.keylist.append(key) - self.valuelist.append(value) + try: + i = self.keylist.index(key) + self.valuelist[i] = value + except ValueError: + self.keylist.append(key) + self.valuelist.append(value) def __delitem__(self, key): try: i = self.keylist.index(key)