[packages/vtk] Rel 21. Fix segfault on import with Python 3.13 (upstream 675929762a)

arekm arekm at pld-linux.org
Mon Sep 28 13:47:40 CEST 2026


commit 9c11505a15203e32f215fdb86c95f00759e842a3
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Mon Sep 28 13:47:04 2026 +0200

    Rel 21. Fix segfault on import with Python 3.13 (upstream 675929762a)

 python3.13.patch | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 vtk.spec         |  4 +++-
 2 files changed, 52 insertions(+), 1 deletion(-)
---
diff --git a/vtk.spec b/vtk.spec
index 0ac1d1d..b2f3e08 100644
--- a/vtk.spec
+++ b/vtk.spec
@@ -24,7 +24,7 @@ Summary:	Toolkit for 3D computer graphics, image processing, and visualization
 Summary(pl.UTF-8):	Zestaw narzędzi do trójwymiarowej grafiki, przetwarzania obrazu i wizualizacji
 Name:		vtk
 Version:	9.3.1
-Release:	20
+Release:	21
 License:	BSD
 Group:		Libraries
 #Source0Download: https://vtk.org/download/
@@ -35,6 +35,7 @@ Source1:	https://www.vtk.org/files/release/9.3/VTKData-%{version}.tar.gz
 Patch0:		ffmpeg6.patch
 Patch1:		netcdf.patch
 Patch2:		build.patch
+Patch3:		python3.13.patch
 URL:		https://vtk.org/
 %{?with_OSMesa:BuildRequires: Mesa-libOSMesa-devel}
 BuildRequires:	OpenGL-GLX-devel
@@ -344,6 +345,7 @@ potrzebne do uruchamiania różnych przykładów z pakietu vtk-examples.
 %patch -P 0 -p1
 %patch -P 1 -p1
 %patch -P 2 -p1
+%patch -P 3 -p1
 
 # Replace relative path ../../../VTKData with destination filesystem path
 grep -Erl '(\.\./)+VTKData' Examples | xargs \
diff --git a/python3.13.patch b/python3.13.patch
new file mode 100644
index 0000000..6b6ca82
--- /dev/null
+++ b/python3.13.patch
@@ -0,0 +1,49 @@
+From 675929762a09ad0b40cb2667918a7061c47a418c Mon Sep 17 00:00:00 2001
+From: David Gobbi <david.gobbi at gmail.com>
+Date: Sat, 14 Sep 2024 08:35:21 -0600
+Subject: [PATCH] Python 3.13 fix for missing dict segfault
+
+Python 3.13 removed a safety net from PyModule_Type's tp_init slot
+that created the module's md_dict member if it was NULL.  This
+safety net was removed because, since Python 3.11, the md_dict is
+created by tp_new and is never expected to be NULL.  So, in our
+own code, we must ensure that tp_new is called before tp_init.
+---
+ Wrapping/PythonCore/PyVTKNamespace.cxx | 6 ++++--
+ Wrapping/PythonCore/PyVTKTemplate.cxx  | 6 ++++--
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/Wrapping/PythonCore/PyVTKNamespace.cxx b/Wrapping/PythonCore/PyVTKNamespace.cxx
+index bed60dc47cb..c1823084086 100644
+--- a/Wrapping/PythonCore/PyVTKNamespace.cxx
++++ b/Wrapping/PythonCore/PyVTKNamespace.cxx
+@@ -112,8 +112,10 @@ PyObject* PyVTKNamespace_New(const char* name)
+   {
+     // make sure python has readied the type object
+     PyType_Ready(&PyVTKNamespace_Type);
+-    // call the allocator provided by python for this type
+-    self = PyVTKNamespace_Type.tp_alloc(&PyVTKNamespace_Type, 0);
++    // call the superclass new function
++    PyObject* empty = PyTuple_New(0);
++    self = PyVTKNamespace_Type.tp_base->tp_new(&PyVTKNamespace_Type, empty, nullptr);
++    Py_DECREF(empty);
+     // call the superclass init function
+     PyObject* pyname = PyUnicode_FromString(name);
+     PyObject* args = PyTuple_Pack(1, pyname);
+diff --git a/Wrapping/PythonCore/PyVTKTemplate.cxx b/Wrapping/PythonCore/PyVTKTemplate.cxx
+index 26421f60f07..e7780bf1007 100644
+--- a/Wrapping/PythonCore/PyVTKTemplate.cxx
++++ b/Wrapping/PythonCore/PyVTKTemplate.cxx
+@@ -761,8 +761,10 @@ PyObject* PyVTKTemplate_New(const char* name, const char* docstring)
+ {
+   // make sure python has readied the type object
+   PyType_Ready(&PyVTKTemplate_Type);
+-  // call the allocator provided by python for this type
+-  PyObject* self = PyVTKTemplate_Type.tp_alloc(&PyVTKTemplate_Type, 0);
++  // call the superclass new function
++  PyObject* empty = PyTuple_New(0);
++  PyObject* self = PyVTKTemplate_Type.tp_base->tp_new(&PyVTKTemplate_Type, empty, nullptr);
++  Py_DECREF(empty);
+   // call the superclass init function
+   PyObject* pyname = PyUnicode_FromString(name);
+   PyObject* pydoc = PyUnicode_FromString(docstring);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/vtk.git/commitdiff/9c11505a15203e32f215fdb86c95f00759e842a3



More information about the pld-cvs-commit mailing list