Gdk.cairo_region_create_from_surface() raises an error in GI

Bug #1028115 reported by David Klasinc on 2012-07-23
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Fix Released
py3cairo (Debian)
Fix Released
py3cairo (Ubuntu)
pygobject (Ubuntu)
Martin Pitt

Bug Description

This happens on current 12.10 daily:

>>> from gi.repository import Gdk
>>> import cairo
>>> surface = cairo.ImageSurface(0, 100, 100)
>>> Gdk.cairo_region_create_from_surface(surface)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gi/", line 47, in function
    return info.invoke(*args, **kwargs)
TypeError: Couldn't find conversion for foreign struct 'cairo.Region'

Upstream has some additional info and a couple of patches for this:

Martin Pitt (pitti) wrote :

py3cairo patch is committed upstream, this needs a new release and then we can apply the patch to pygobject.

Changed in pygobject (Ubuntu):
status: New → Triaged
Changed in py3cairo (Ubuntu):
status: New → Fix Committed
Martin Pitt (pitti) on 2012-09-17
Changed in pygobject (Ubuntu):
status: Triaged → Fix Committed
status: Fix Committed → In Progress
Koichi Akabe (vbkaisetsu) wrote :


Thanks for reporting. I'm considering positively to apply this patch in py3cairo, but I can't use my pc with the internet until Thursday.

Martin, could you forward this bug to debian BTS? I'll close it in the new package.

Changed in pygobject:
importance: Unknown → Medium
status: Unknown → Confirmed
Martin Pitt (pitti) wrote :

Koichi, I reported this to Debian and linked it here. Thanks!

Changed in py3cairo (Debian):
status: Unknown → New
Martin Pitt (pitti) wrote :

Synced, thanks Koichi!

py3cairo (1.10.0+dfsg-3~exp2) experimental; urgency=low

  * debian/patches/101_pycairo-region.patch
   - add support for cairo_region_t (Closes: 688079)

 -- Koichi Akabe <email address hidden> Thu, 20 Sep 2012 16:14:24 +0900

py3cairo (1.10.0+dfsg-3~exp1) experimental; urgency=low

  * debian/rules
   - support DEB_BUILD_OPTIONS=nocheck (Closes: #681034)
   - add -v flag to waf to output verbose log
  * debian/compat
   - up to 9 to add hardening flags
  * debian/control
   - update debhelper version to 9
   - enable DM-Upload

 -- Koichi Akabe <email address hidden> Tue, 10 Jul 2012 22:52:04 +0900

Changed in py3cairo (Ubuntu):
status: Fix Committed → Fix Released
Changed in py3cairo (Debian):
status: New → Fix Released
fossfreedom (fossfreedom) wrote :

We have a rhythmbox plugin that requires these patches.

We can confirm they work great on 12.04 & 12.10

i.e. patches for the following packages:

python-cairo, python3-cairo, python-gi, python-gi-cairo

The patches for both precise and github can be found on Github.

Seems to me - these patches fix something that never worked - as such there should not be any regression potential here.

Any chance including these patches in an official update or backport?


Martin Pitt (pitti) wrote :

I was hoping upstream pycairo would do a release at some point. I can't apply the pygobject patch upstream until then, but I'll apply it to the Ubuntu package for the time being.

Changed in pygobject (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygobject -

pygobject ( raring; urgency=low

  * New upstream release
  * Add 01_cairo_region.patch: Add foreign type for cairo_region_t.
    Debian/Ubuntu's pycairo packages have support for this backported from
    trunk, need to keep this as a patch until there is a new pycairo upstream
    release. (LP: #1028115)
  * Add disable_micro_version_test.patch: Disable microversion test for "5.1"
    microversion. Can be dropped at next upstream release.
 -- Martin Pitt <email address hidden> Mon, 11 Feb 2013 08:22:21 +0100

Changed in pygobject (Ubuntu):
status: In Progress → Fix Released
Mirco Müller (macslow) wrote :

Just want to add my 2 cents of information from messing with this subject over the weekend...

To properly use cairo.Region() in Python one needs at least pycairo 1.8.10 (1.10.0 is current) for Python 3.x. For Python 2.x pycairo does not support/implement cairo.Region().

I've an example implementing "click-through" using cairo.Region() and cairo.RectangleInt() available here:

Changed in pygobject:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.