From 1ef1ea2f0ba3854309114a2395734c34a1e158d8 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Mon, 16 Oct 2023 20:01:52 -0600 Subject: [PATCH] module: reorder cairo script surface initialization 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 --- cairo/cairomodule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cairo/cairomodule.c b/cairo/cairomodule.c index 0026a0e..f27330f 100644 --- a/cairo/cairomodule.c +++ b/cairo/cairomodule.c @@ -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; @@ -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;