Currently: py> tup = ([], ) py> tup[0] += [1] Traceback (most recent call last): File "", line 1, in ? TypeError: object doesn't support item assignment py> tup ([1],) With this patch, no exception will be raised when the item one wants to assign is already there in the tuple.
Logged In: YES user_id=6380 I see no error handling from the PySequence_GetItem() call; if this causes an error it should take precedence over the TypeError we're about to raise (IOW we shouldn't raise the TypeError). Also, shouldn't the same fix be made for attribute assignment? Finally -- doing this in PySequence_SetItem is too broad. Code like this passes without error: t = (1, 2) t[0] = t[0] That can't be right! You need to find a code path that's only taken for += and friends.
Logged In: YES user_id=849994 You're right with the error handling *shame*. I had written the patch a few months ago and just posted it without looking at it again. Well, I don't think I'm able to come up with a new patch only for a couple of days.