[pypy-dev] A problem with unbound methods

Antonio Cuni anto.cuni at gmail.com
Thu Apr 6 13:03:21 CEST 2006


Hi,
I have some problems for translating calls to unbound methods.
Let's show with an example:

class MyClass:
     def __init__(self, x):
         self.x = x

class MyDerivedClass(MyClass):
     def __init__(self, x):
         MyClass.__init__(self, x)

During rtyping the field and method names are mangled, so the __init__ 
method became something like 'o__init____variant0': as long as I call 
bound methods this is not a problem because the low-level op oosend 
contains the right mangled name, but difficult arises when I try to call 
an unbound method such as the one showed above; the low-level op that I 
obtain is this:

v9 = direct_call((<pypy.rpython.ootypesystem.ootype._static_meth object 
at 0xb78e51ac>), self_1, x_2)

Let 'x = op.args[0].value':

(Pdb) x._name
'Base.__init__'
(Pdb) x.graph.name
'Base.__init__'

As you can see I can read only the original unmangled name, but it is 
useless because I've to deal with the mangled one.
I've tried to search around for a place where to read that but I 
couldn't find it. How can I do?

thanks for the help
ciao Anto



More information about the Pypy-dev mailing list