[ python-Bugs-1682749 ] next method assignment is ignored in new-style classes

SourceForge.net noreply at sourceforge.net
Sat Mar 17 17:27:03 CET 2007


Bugs item #1682749, was opened at 2007-03-17 15:06
Message generated for change (Comment added) made by albert2611
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1682749&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.5
>Status: Open
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Albert Weichselbraun (albert2611)
Assigned to: Neal Norwitz (nnorwitz)
Summary: next method assignment is ignored in new-style classes

Initial Comment:
in old-style classes the next method of an iterator-superclass can be "overwritten" using

self.next = self.new_next_method

when new-style classes are used the assignment is ignored and instead of new_next_method the next method of the superclass is called when the class is used as iterator (tested for python2.3-2.5 under debian/linux).
- if the next() method is called directly, the assigned
  method is used (see attached code example).


----------------------------------------------------------------------

>Comment By: Albert Weichselbraun (albert2611)
Date: 2007-03-17 16:27

Message:
Logged In: YES 
user_id=806170
Originator: YES

i only experienced this behavior for the next method in iterator classes.
overwriting methods with other names using an assignment works as
expected.


----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-17 15:52

Message:
Logged In: YES 
user_id=849994
Originator: NO

This is another incarnation of __methods__ being looked up on the type,
not the instance, except that next() is not a __method__ yet.

For new-style classes, this behavior is considered correct. Neal?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1682749&group_id=5470


More information about the Python-bugs-list mailing list