Following script: surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10) context = cairo.Context(surface) source_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10) context.set_source_surface(source_surface) context.get_source().get_surface() fails with: Traceback (most recent call last): File "bug.py", line 7, in <module> context.get_source().get_surface() SystemError: NULL object passed to Py_BuildValue Reason: get_source passes NULL to PycairoPattern_FromPattern: static PyObject * pycairo_get_source (PycairoContext *o) { return PycairoPattern_FromPattern ( cairo_pattern_reference (cairo_get_source (o->ctx)), NULL); } PycairoPattern_FromPattern stores NULL to "base" field: PyObject * PycairoPattern_FromPattern (cairo_pattern_t *pattern, PyObject *base) { ... Py_XINCREF(base); ((PycairoPattern *)o)->base = base; ... } get_surface returns "base" field: static PyObject * surface_pattern_get_surface (PycairoSurfacePattern *o) { return Py_BuildValue("O", o->base); }
Thanks for the bug report, its now fixed in git. I had assumed the only way to create a surface pattern was using cairo.SurfacePattern() but as your example shows you can bypass this by calling context.set_source_surface() and pattern = context.get_source()
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.