[Pyrex] BUG: a problem with type casting in __richcmp__...
    Alexander A Naanou 
    alex_nanou at pochtamt.ru
       
    Thu May 22 22:18:04 CEST 2003
    
    
  
Hi All!!
Problem:
the goal was to access the *private* var directly...
Here is a peace of code that worked as intended:
---cut---
cdef public class callproxy:
	cdef obj
	# ... (other stuff)
	def __cmp__(self, other):
		cdef callproxy tmp
		if type(other) == callproxy:
			tmp = other
			return self.obj.__cmp__(tmp.obj)
		return self.obj.__cmp__(other)
	# ... (other stuff)
---uncut---
and here is the method that broke!! (in the same class)
---cut---
	# ... (code from prev. snippet)
	# this is stripped down to a state just enought to reproduce the bug..
	def __richcmp__(self, other, int op):
		cdef callproxy tmp
		if type(other) == callproxy:
			tmp = other
			# ...
			return self.obj.__cmp__(tmp.obj)
		# ...
---uncut---
what happend is in the line "return self.obj.__cmp__(tmp.obj)" we got a python 
(e.g. indirect) lookup, where as in the method __cmp__ a correct cast and 
direct lookup.
I did not yet look into the generated C code, but I see no difference in the 
source Pyrex code other than the method declaration...
Thanks.
                                                        With Respect..
                                                                  Alex.
    
    
More information about the Pyrex
mailing list