Has comparison of instancemethods changed between python 2.5 and 2.4?

F

Frank Niessink

Hi,

I'm trying to get an application working with Python 2.5 that works fine
with Python 2.4. This issue occurs both on Windows XP as well as on Mac OSX.

Some context: I use the publisher/subscribe pattern. Observers can
register a callback with a central 'Publisher' like this:

def registerObserver(self, observer, eventType):
''' Register an observer for an event type. The observer is a
callback method that should expect one argument, an instance
of class Event defined above.
The eventType can be anything hashable, typically a string. '''
observerList = self.__observers.setdefault(eventType, [])
if observer not in observerList:
observerList.append(observer)


Now, with Python 2.5 (and not with Python 2.4) I have a callback that is
not being added to the list because, apparently, it compares equal to
some of the callbacks already in the list. However, the instance the two
methods belong to are different, i.e. id(callback) returns different
values for the two methods. Both callbacks are of type <type
'instancemethod'>. Further investigation shows that "observer ==
observerList[1]" is True.

Has instancemethod.__cmp__ changed between python 2.4 and 2.5?

Thanks, Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top