Bugs item #1317376, was opened at 2005-10-08 02:27 Message generated for change (Comment added) made by capnstabn You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1317376&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: capnSTABN (capnstabn) Assigned to: Nobody/Anonymous (nobody) Summary: irregular behavior within class using __setitem__ Initial Comment: i found two bugs vaguely similar to this posted but i think they were different bugs in theory, and both were deemed 'features' anyway so ... :p basically the class is a modified list, being used as a queue what happens is, when hotswapping the __setitem__ functionality, unless explicitly calling __setitem__, the old __setitem__ continues to be called this is very odd and as far as i can tell the behavior is undocumented class Queue(list): def __setitem__(self, a, v): print "old setitem" def mysetitem(self, i, v): print "new setitem" def use_mysetitem(self): self.__setitem__ = self.mysetitem x = Queue() x[1] = 2 x.__setitem__(2, 3) x.use_mysetitem() x[3] = 4 x.__setitem__(4, 5) ---------------------------------------------------------------------- >Comment By: capnSTABN (capnstabn) Date: 2005-10-08 03:14 Message: Logged In: YES user_id=1126596 err, yeh it does 8) the last TWO prints should display new setitem ---------------------------------------------------------------------- Comment By: Nick Coghlan (ncoghlan) Date: 2005-10-08 03:09 Message: Logged In: YES user_id=1038590 This problem doesn't exist in Python 2.4: Py> class Queue(list): ... def __setitem__(self, a, v): ... print "old setitem" ... def mysetitem(self, i, v): ... print "new setitem" ... def use_mysetitem(self): ... self.__setitem__ = self.mysetitem ... Py> x = Queue() Py> Py> x[1] = 2 old setitem Py> Py> x.__setitem__(2, 3) old setitem Py> Py> x.use_mysetitem() Py> x[3] = 4 old setitem Py> Py> x.__setitem__(4, 5) new setitem ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1317376&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com