[ python-Bugs-1317376 ] irregular behavior within class using __setitem__
SourceForge.net
noreply at sourceforge.net
Sat Oct 8 09:27:34 CEST 2005
Bugs item #1317376, was opened at 2005-10-08 02:27
Message generated for change (Tracker Item Submitted) made by Item Submitter
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)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1317376&group_id=5470
More information about the Python-bugs-list
mailing list