Skip to content

Commit

Permalink
module: reorder cairo script surface initialization
Browse files Browse the repository at this point in the history
PyType_Ready() expects subclasses to be initialized after base classes.
Since ScriptSurface inherits from Surface, Surface must be initialized
first.

This causes a segfault in pypy3.10, and the fix was suggested here:

https://foss.heptapod.net/pypy/pypy/-/issues/4017#note_332375

This fixes the seg fault for me.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
  • Loading branch information
tych0 authored and lazka committed Oct 21, 2023
1 parent 6405839 commit 64733c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cairo/cairomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ PYCAIRO_MODINIT_FUNC PyInit__cairo(void)
if (PyType_Ready(&PycairoTextExtents_Type) < 0)
return NULL;

if (PyType_Ready(&PycairoSurface_Type) < 0)
return NULL;

#ifdef CAIRO_HAS_SCRIPT_SURFACE
if (PyType_Ready(&PycairoScriptDevice_Type) < 0)
return NULL;
Expand All @@ -223,8 +226,6 @@ PYCAIRO_MODINIT_FUNC PyInit__cairo(void)
if (PyType_Ready(&PycairoScaledFont_Type) < 0)
return NULL;

if (PyType_Ready(&PycairoSurface_Type) < 0)
return NULL;
#ifdef CAIRO_HAS_IMAGE_SURFACE
if (PyType_Ready(&PycairoImageSurface_Type) < 0)
return NULL;
Expand Down

0 comments on commit 64733c1

Please sign in to comment.