After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 489571 - ctypes interop
ctypes interop
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: codegen
2.15.x
Other Linux
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2007-10-23 21:04 UTC by Behdad Esfahbod
Modified: 2012-04-20 09:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Behdad Esfahbod 2007-10-23 21:04:04 UTC
To make life easier for users that find their favorite API left out of python bindings, it would be dramatically useful to have two ctypes interop features:

  - Constructors for all GObject's and GBoxed's (possibly other types) should accept a ctypes.c_void_p and just create a proxy for that and return it.

  - All objects should have a method, get_c_void_p or whatever, that returns ctypes.c_void_p pointers of the underlying C object.

Thanks.
Comment 1 Behdad Esfahbod 2007-10-24 00:09:37 UTC
Humm, seems like id(obj) should return the C pointer address.  Not sure if pygtk does that.
Comment 2 Johan (not receiving bugmail) Dahlin 2007-10-24 07:20:21 UTC
Behdad: You can use hash() on GObjects to get the C pointer address.

id(obj) gets the a pointer address, but of the python wrapper object and not the original "C" structure.
Comment 3 Behdad Esfahbod 2007-10-24 16:07:00 UTC
(In reply to comment #2)
> Behdad: You can use hash() on GObjects to get the C pointer address.

Except that for example I asked you and you changed hash(pango.FontDescription()) to return pango_font_description_hash().  That is, there's no guarantee that has() returns the C pointer address, right?

> id(obj) gets the a pointer address, but of the python wrapper object and not
> the original "C" structure.

Right, found that out...
Comment 4 Behdad Esfahbod 2007-10-24 16:17:56 UTC
FWIW, this is what one ends up doing if they don't have proper support for these things:

   http://cairographics.org//freetypepython
Comment 5 Dieter Verfaillie 2012-04-20 09:09:31 UTC
Thanks for taking the time to report this bug. However, this
bug report applies to a PyGObject version that is too old and
not supported anymore. PyGObject developers are no longer working
on static bindings, so unfortunately there will not be any bug
fixes for the version this report applies to.
 
By upgrading to a newer version of PyGObject you could receive
bug fixes and new functionality. Please feel free to reopen this
bug if the problem still occurs with a newer version of PyGObject.