Issue 1436226: fix inplace assignment for immutable sequences (original) (raw)

Created on 2006-02-21 22:11 by georg.brandl, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg27581 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-21 22:11
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.
msg27582 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2006-02-22 01:44
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.
msg27583 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-22 21:20
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.
msg27584 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-08-10 07:23
Logged In: YES user_id=849994 This is actually not supposed to work, says Guido.
History
Date User Action Args
2022-04-11 14:56:15 admin set github: 42932
2006-02-21 22:11:44 georg.brandl create