[pygtk] Unable to implement virtual method using the same name

Sébastien Granjoux seb.sfo at free.fr
Tue May 20 05:05:00 WST 2008


Hi All,

I'm trying to write some python bindings for Anjuta.

I have hit an issue with pygtk which is reported as bug #503668 (
http://bugzilla.gnome.org/show_bug.cgi?id=503668). Anjuta library uses 
quite a lots of GInterface and an object (typically a plugin) can 
implement several interfaces. But two interfaces could have functions 
with the same name.

In C, it's not a problem because all interface functions are prefixed by 
the interface name. In Python, it is an issue because it's not the case.

I have written a patch to fix this. It adds an additional attribute 
vmethod allowing to specify the name of the overridden C function which 
can be different from the python function name. If this attribute is not 
present the same name is used for both, so the backward compatibility is 
kept (it's mandatory). By example I can have

(define-virtual clear_indicable
   (of-object "IAnjutaIndicable")
   (c-name "ianjuta_indicable_clear")
   (vmethod "clear")
   (return-type "none")
   (parameters
     '("GError**" "err")
   )
)

Here, the python function name is clear_indicable, while the C method is 
clear.


I have get some comments about this patch and I have taken them into 
account but it's now stuck for several months. I haven't pushed it that 
much because I have get other priorities (Anjuta 2.4.x). But now we 
would like to have working python bindings for the next release of GNOME 
and a few people have started to work on this, there is a small web site 
too http://libanjutapython.sourceforge.net/

Could I get this patch upstream, or could you tell me what should be 
improved or why it cannot be committed ?

Regards,

Sébastien


More information about the pygtk mailing list