From 7f3c4ff630f3e20a2012ddc85ace094b6ddac530 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 25 Jun 2025 18:36:40 -0400 Subject: [PATCH 1/7] Add Python 3.14 support https://github.com/swig/swig/pull/3159 --- swig-python-Python-3.14-support.patch | 153 ++++++++++++++++++++++++++ swig.spec | 7 +- 2 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 swig-python-Python-3.14-support.patch diff --git a/swig-python-Python-3.14-support.patch b/swig-python-Python-3.14-support.patch new file mode 100644 index 0000000..ceee305 --- /dev/null +++ b/swig-python-Python-3.14-support.patch @@ -0,0 +1,153 @@ +From 50e1cc8bc0d090164762ec166439f8b0f3855308 Mon Sep 17 00:00:00 2001 +From: Julien Schueller +Date: Thu, 10 Apr 2025 17:22:15 +0200 +Subject: [PATCH 1/3] Python: Handle __package__ removal + +Closes #2967 +--- + Doc/Manual/Python.html | 6 +++--- + Source/Modules/python.cxx | 8 +++++--- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html +index 23587e5dbcc..01fc449a68a 100644 +--- a/Doc/Manual/Python.html ++++ b/Doc/Manual/Python.html +@@ -6552,7 +6552,7 @@

33.11.6.1 Both modules + +

+ In this configuration, the pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is +-located in. The package name is determined from the __package__ ++located in. The package name is determined from the __spec__.parent (or __package__ before Python 3.4) + attribute if available, see PEP 366. Otherwise it is derived from the __name__ + attribute given to foo.py by the Python loader that imported foo.py. + The interface file for this configuration would contain: +@@ -6675,7 +6675,7 @@

33.11.6.4 More on customizing the modu + +
+
+-if __package__ or '.' in __name__:
++if getattr(__spec__, "parent", None) or '.' in __name__:
+     from . import _foo
+ else:
+     import _foo
+@@ -6760,7 +6760,7 @@ 

33.11.6.4 More on customizing the modu + +
+
+-if __package__ or '.' in __name__:
++if getattr(__spec__, "parent", None) or '.' in __name__:
+     from ._foo import *
+ else:
+     from _foo import *
+diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
+index 86daf131c8b..a71fc3cdb25 100644
+--- a/Source/Modules/python.cxx
++++ b/Source/Modules/python.cxx
+@@ -703,20 +703,22 @@ class PYTHON:public Language {
+ 	 * onwards (implicit relative imports raised a DeprecationWarning in 2.6,
+ 	 * and fail in 2.7 onwards).
+ 	 *
+-	 * First check for __package__ which is available from 2.6 onwards, see PEP366.
++	 * First check for __spec__.parent which is available from 3.4 onwards,
++	 * see https://docs.python.org/3/reference/import.html#spec. If not,
++	 * check for __package__, which was set before 3.14.
+ 	 * Next try determine the shadow wrapper's package based on the __name__ it
+ 	 * was given by the importer that loaded it.
+ 	 * If the module is in a package, load the low-level C/C++ module from the
+ 	 * same package, otherwise load it as a global module.
+ 	 */
+         Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL);
+-        Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
++        Printv(default_import_code, "if getattr(globals().get(\"__spec__\"), \"parent\", None) or globals().get(\"__package__\") or \".\" in __name__:\n", NULL);
+         Printv(default_import_code, tab4, "from . import ", module, "\n", NULL);
+         Printv(default_import_code, "else:\n", NULL);
+         Printv(default_import_code, tab4, "import ", module, "\n", NULL);
+       } else {
+         Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL);
+-        Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
++        Printv(default_import_code, "if getattr(globals().get(\"__spec__\"), \"parent\", None) or globals().get(\"__package__\") or \".\" in __name__:\n", NULL);
+         Printv(default_import_code, tab4, "from .", module, " import *\n", NULL);
+         Printv(default_import_code, "else:\n", NULL);
+         Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
+
+From 3bfdf13c602f877860a9949ba751a5b5a9ba70aa Mon Sep 17 00:00:00 2001
+From: Julien Schueller 
+Date: Thu, 10 Apr 2025 18:35:25 +0200
+Subject: [PATCH 2/3] Python: Add ht_token
+
+---
+ Source/Modules/python.cxx | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
+index a71fc3cdb25..3070a94face 100644
+--- a/Source/Modules/python.cxx
++++ b/Source/Modules/python.cxx
+@@ -4374,6 +4374,11 @@ class PYTHON:public Language {
+     Printv(f, "#if PY_VERSION_HEX >= 0x030b0000\n", NIL);
+     printSlot(f, getSlot(n, "feature:python:_ht_tpname"), "_ht_tpname", "char *");
+ 
++    // void *ht_token;
++    Printv(f, "#if PY_VERSION_HEX >= 0x030e0000\n", NIL);
++    printSlot(f, getSlot(n, "feature:python:ht_token"), "ht_token", "void *");
++    Printv(f, "#endif\n", NIL);
++
+     // struct _specialization_cache _spec_cache;
+     Printf(f, "  {\n");
+     printSlot(f, getSlot(n, "feature:python:getitem"), "getitem", "PyObject *");
+
+From 55237efa7219f65a04e0ffc69a81c574b5f5e162 Mon Sep 17 00:00:00 2001
+From: Julien Schueller 
+Date: Thu, 10 Apr 2025 17:47:59 +0200
+Subject: [PATCH 3/3] Python: Amend annotations test
+
+---
+ .../python_annotations_variable_c_runme.py    | 24 +++++++++++++------
+ 1 file changed, 17 insertions(+), 7 deletions(-)
+
+diff --git a/Examples/test-suite/python/python_annotations_variable_c_runme.py b/Examples/test-suite/python/python_annotations_variable_c_runme.py
+index 153852d05e6..d1f359bbbd0 100644
+--- a/Examples/test-suite/python/python_annotations_variable_c_runme.py
++++ b/Examples/test-suite/python/python_annotations_variable_c_runme.py
+@@ -1,4 +1,17 @@
+ import sys
++import inspect
++
++
++def get_annotations(cls):
++    # Python >=3.14 removed the __annotations__ attribute
++    # retrieve it via inspect (see also annotationlib)
++    if hasattr(inspect, "get_annotations"):
++        # Python >=3.10
++        return inspect.get_annotations(cls)
++    else:
++        # Python <3.10
++        return getattr(cls, "__annotations__", {})
++
+ 
+ # Variable annotations for properties is only supported in python-3.6 and later (PEP 526)
+ if sys.version_info[0:2] >= (3, 6):
+@@ -8,17 +21,14 @@
+     annotations_supported = not(is_python_builtin() or is_python_fastproxy())
+ 
+     if annotations_supported:
+-        ts = TemplateShort()
+-        anno = ts.__annotations__
++        anno = get_annotations(TemplateShort)
+         if anno != {'member_variable': 'int'}:
+             raise RuntimeError("annotations mismatch: {}".format(anno))
+ 
+-        ts = StructWithVar()
+-        anno = ts.__annotations__
++        anno = get_annotations(StructWithVar)
+         if anno != {'member_variable': 'int'}:
+             raise RuntimeError("annotations mismatch: {}".format(anno))
+ 
+-        ts = StructWithVarNotAnnotated()
+-        if getattr(ts, "__annotations__", None) != None:
+-            anno = ts.__annotations__
++        anno = get_annotations(StructWithVarNotAnnotated)
++        if anno != {}:
+             raise RuntimeError("annotations mismatch: {}".format(anno))
+
diff --git a/swig.spec b/swig.spec
index 2e82a1c..52a6616 100644
--- a/swig.spec
+++ b/swig.spec
@@ -69,7 +69,7 @@
 Summary: Connects C/C++/Objective C to some high-level programming languages
 Name:    swig
 Version: 4.3.1
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPL-3.0-or-later AND BSD-3-Clause
 URL:     https://www.swig.org/
 Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
@@ -80,6 +80,8 @@ Source2: description-ccache.h2m
 Source3: ccache-swig.sh
 Source4: ccache-swig.csh
 %endif
+# https://github.com/swig/swig/pull/3159
+Patch0:  swig-python-Python-3.14-support.patch
 
 BuildRequires: coreutils
 BuildRequires: findutils
@@ -363,6 +365,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb
 %{_datadir}/%{name}/gdb
 
 %changelog
+* Wed Jun 25 2025 Yaakov Selkowitz  - 4.3.1-2
+- Add Python 3.14 support
+
 * Wed Apr 16 2025 Jitka Plesnikova  - 4.3.1-1
 - 4.3.1 bump (rhbz#2360009)
 

From 36cdf9d2565f04870eac469e86c73f279a17abde Mon Sep 17 00:00:00 2001
From: Fedora Release Engineering 
Date: Fri, 25 Jul 2025 18:57:56 +0000
Subject: [PATCH 2/7] Rebuilt for
 https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild

---
 swig.spec | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/swig.spec b/swig.spec
index 52a6616..9c690f1 100644
--- a/swig.spec
+++ b/swig.spec
@@ -69,7 +69,7 @@
 Summary: Connects C/C++/Objective C to some high-level programming languages
 Name:    swig
 Version: 4.3.1
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPL-3.0-or-later AND BSD-3-Clause
 URL:     https://www.swig.org/
 Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
@@ -365,6 +365,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb
 %{_datadir}/%{name}/gdb
 
 %changelog
+* Fri Jul 25 2025 Fedora Release Engineering  - 4.3.1-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
+
 * Wed Jun 25 2025 Yaakov Selkowitz  - 4.3.1-2
 - Add Python 3.14 support
 

From 9a1f1a1a5575241606cc61722646c78ff8001450 Mon Sep 17 00:00:00 2001
From: Jitka Plesnikova 
Date: Fri, 1 Aug 2025 10:27:48 +0200
Subject: [PATCH 3/7] Fix Python DeprecationWarning

---
 ....4.0-Python-DeprecationWarning-fixes.patch | 806 ++++++++++++++++++
 swig.spec                                     |   8 +-
 2 files changed, 813 insertions(+), 1 deletion(-)
 create mode 100644 swig-4.4.0-Python-DeprecationWarning-fixes.patch

diff --git a/swig-4.4.0-Python-DeprecationWarning-fixes.patch b/swig-4.4.0-Python-DeprecationWarning-fixes.patch
new file mode 100644
index 0000000..17b9246
--- /dev/null
+++ b/swig-4.4.0-Python-DeprecationWarning-fixes.patch
@@ -0,0 +1,806 @@
+From 49a7d2b0c6aed00bd07a9a28569020d560c2658c Mon Sep 17 00:00:00 2001
+From: William S Fulton 
+Date: Sat, 10 May 2025 13:47:35 +0100
+Subject: [PATCH 1/5] Python DeprecationWarning fixes
+
+DeprecationWarning fixes when using 'python -Walways' or if using one of the types being warned about:
+
+  DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute
+  DeprecationWarning: builtin type SwigPyObject has no __module__ attribute
+  DeprecationWarning: builtin type swigvarlink has no __module__ attribute
+
+The warning was present if code was generated without using -builtin in 4.3.x.
+The warning was only present if using the Python limited API in 4.2.1 and earlier.
+
+These 3 types were not in any module at all. Now they are in the swig runtime module.
+Docs to follow.
+
+Issue #2881
+Issue #3061
+Issue #3160
+---
+ CHANGES.current       | 11 +++++++++++
+ Lib/python/pyhead.swg |  4 +++-
+ Lib/python/pyrun.swg  | 22 +++++++++++-----------
+ 3 files changed, 25 insertions(+), 12 deletions(-)
+
+#diff --git a/CHANGES.current b/CHANGES.current
+#index 99c8a1d8f..0bce7937f 100644
+#--- a/CHANGES.current
+#+++ b/CHANGES.current
+#@@ -7,6 +7,17 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
+# Version 4.4.0 (in progress)
+# ===========================
+# 
+#+2025-05-10: jschueller, wsfulton
+#+            [Python] #2881 #3061 #3160 DeprecationWarning fixes when using 'python -Walways'
+#+            or if using one of the types being warned about:
+#+
+#+              DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute
+#+              DeprecationWarning: builtin type SwigPyObject has no __module__ attribute
+#+              DeprecationWarning: builtin type swigvarlink has no __module__ attribute
+#+
+#+            The warning was present if code was generated without using -builtin in 4.3.x.
+#+            The warning was only present if using the Python limited API in 4.2.1 and earlier.
+#+
+# 2025-04-30: wsfulton
+#             [Python] #3134 Fix maximum size of strings being marshalled from C/C++
+#             into Python. This has been changed from INT_MAX to PY_SSIZE_T_MAX in line
+diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
+index 50dca5bc0..4f238b9f6 100644
+--- a/Lib/python/pyhead.swg
++++ b/Lib/python/pyhead.swg
+@@ -60,6 +60,8 @@ SWIG_Python_str_FromChar(const char *c)
+ #endif
+ }
+ 
++#define SWIG_RUNTIME_MODULE "swig_runtime_data" SWIG_RUNTIME_VERSION
++
+ /* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */
+ # define SWIGPY_USE_CAPSULE
+ #ifdef SWIGPYTHON_BUILTIN
+@@ -67,7 +69,7 @@ SWIG_Python_str_FromChar(const char *c)
+ #else
+ # define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule" SWIG_TYPE_TABLE_NAME
+ #endif
+-# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION "." SWIGPY_CAPSULE_ATTR_NAME)
++#define SWIGPY_CAPSULE_NAME SWIG_RUNTIME_MODULE "." SWIGPY_CAPSULE_ATTR_NAME
+ 
+ #if PY_VERSION_HEX < 0x03020000
+ #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
+diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
+index 77d7fccfa..b9e3e7241 100644
+--- a/Lib/python/pyrun.swg
++++ b/Lib/python/pyrun.swg
+@@ -353,7 +353,7 @@ swig_varlink_type(void) {
+       PyObject_HEAD_INIT(NULL)
+       0,                                  /* ob_size */
+ #endif
+-      "swigvarlink",                      /* tp_name */
++      SWIG_RUNTIME_MODULE ".swigvarlink", /* tp_name */
+       sizeof(swig_varlinkobject),         /* tp_basicsize */
+       0,                                  /* tp_itemsize */
+       (destructor) swig_varlink_dealloc,  /* tp_dealloc */
+@@ -424,7 +424,7 @@ swig_varlink_type(void) {
+     { 0, NULL }
+   };
+   PyType_Spec spec = {
+-    "swigvarlink",
++    SWIG_RUNTIME_MODULE ".swigvarlink",
+     sizeof(swig_varlinkobject),
+     0,
+     Py_TPFLAGS_DEFAULT,
+@@ -750,7 +750,7 @@ SwigPyObject_Check(PyObject *op) {
+ #ifdef SWIGPYTHON_BUILTIN
+   if (PyType_IsSubtype(op_type, target_tp))
+     return 1;
+-  return (strcmp(op_type->tp_name, "SwigPyObject") == 0);
++  return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0);
+ #else
+ # ifdef Py_LIMITED_API
+   int cmp;
+@@ -766,7 +766,7 @@ SwigPyObject_Check(PyObject *op) {
+   SWIG_Py_DECREF(tp_name);
+   return cmp == 0;
+ # else
+-  return (strcmp(op_type->tp_name, "SwigPyObject") == 0);
++  return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0);
+ # endif
+ #endif
+ }
+@@ -966,7 +966,7 @@ SwigPyObject_TypeOnce(void) {
+       PyObject_HEAD_INIT(NULL)
+       0,                                    /* ob_size */
+ #endif
+-      "SwigPyObject",                       /* tp_name */
++      SWIG_RUNTIME_MODULE ".SwigPyObject",  /* tp_name */
+       sizeof(SwigPyObject),                 /* tp_basicsize */
+       0,                                    /* tp_itemsize */
+       (destructor)SwigPyObject_dealloc,     /* tp_dealloc */
+@@ -1061,7 +1061,7 @@ SwigPyObject_TypeOnce(void) {
+     { 0, NULL }
+   };
+   PyType_Spec spec = {
+-    "SwigPyObject",
++    SWIG_RUNTIME_MODULE ".SwigPyObject",
+     sizeof(SwigPyObject),
+     0,
+     Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+@@ -1160,7 +1160,7 @@ SwigPyPacked_Check(PyObject *op) {
+   SWIG_Py_DECREF(tp_name);
+   return cmp == 0;
+ #else
+-  return (strcmp(op_type->tp_name, "SwigPyPacked") == 0);
++  return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyPacked") == 0);
+ #endif
+ }
+ 
+@@ -1188,7 +1188,7 @@ SwigPyPacked_TypeOnce(void) {
+       PyObject_HEAD_INIT(NULL)
+       0,                                    /* ob_size */
+ #endif
+-      "SwigPyPacked",                       /* tp_name */
++      SWIG_RUNTIME_MODULE ".SwigPyPacked",  /* tp_name */
+       sizeof(SwigPyPacked),                 /* tp_basicsize */
+       0,                                    /* tp_itemsize */
+       (destructor)SwigPyPacked_dealloc,     /* tp_dealloc */
+@@ -1281,7 +1281,7 @@ SwigPyPacked_TypeOnce(void) {
+     { 0, NULL }
+   };
+   PyType_Spec spec = {
+-    "SwigPyPacked",
++    SWIG_RUNTIME_MODULE ".SwigPyPacked",
+     sizeof(SwigPyPacked),
+     0,
+     Py_TPFLAGS_DEFAULT,
+@@ -1846,10 +1846,10 @@ SWIGRUNTIME void
+ SWIG_Python_SetModule(swig_module_info *swig_module) {
+ #if PY_VERSION_HEX >= 0x03000000
+  /* Add a dummy module object into sys.modules */
+-  PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION);
++  PyObject *module = PyImport_AddModule(SWIG_RUNTIME_MODULE);
+ #else
+   static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
+-  PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
++  PyObject *module = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table);
+ #endif
+   PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
+   if (pointer && module) {
+-- 
+2.50.1
+
+
+From 7ecbb7103dec48bb316baa9ccd71ba7888de7c54 Mon Sep 17 00:00:00 2001
+From: William S Fulton 
+Date: Sun, 11 May 2025 16:02:43 +0100
+Subject: [PATCH 2/5] Add SwigPyObject, SwigPyPacked, swigvarlink to the swig
+ runtime module
+
+Also add SWIG_REFCNT_DEBUG for debugging reference counts when the main
+module is destroyed - there's some work to be done here on reference
+counts!
+---
+ Lib/python/pyinit.swg |  1 +
+ Lib/python/pyrun.swg  | 91 +++++++++++++++++++++++++++++++++----------
+ 2 files changed, 71 insertions(+), 21 deletions(-)
+
+diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
+index 5bf7097f5..4e25323f6 100644
+--- a/Lib/python/pyinit.swg
++++ b/Lib/python/pyinit.swg
+@@ -261,6 +261,7 @@ SWIG_init(void) {
+   (void)globals;
+ 
+   /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */
++  SWIG_runtime_data_module();
+   SWIG_This();
+   SWIG_Python_TypeCache();
+   SwigPyPacked_type();
+diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
+index b9e3e7241..2ef79f348 100644
+--- a/Lib/python/pyrun.swg
++++ b/Lib/python/pyrun.swg
+@@ -114,8 +114,25 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+ 
+ #endif
+ 
+-/* Append a value to the result obj */
++/* SWIG runtime data Python module */
++static PyObject *Swig_runtime_data_module_global = NULL;
++
++/* Create/obtain the single swig_runtime_data module which is used across different SWIG generated modules */
++SWIGINTERN PyObject *
++SWIG_runtime_data_module() {
++  if (!Swig_runtime_data_module_global) {
++#if PY_VERSION_HEX >= 0x03000000
++    Swig_runtime_data_module_global = PyImport_AddModule(SWIG_RUNTIME_MODULE);
++#else
++    static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
++    Swig_runtime_data_module_global = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table);
++#endif
++    SWIG_Py_XINCREF(Swig_runtime_data_module_global);
++  }
++  return Swig_runtime_data_module_global;
++}
+ 
++/* Append a value to the result obj */
+ SWIGINTERN PyObject*
+ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void) {
+   if (!result) {
+@@ -341,7 +358,7 @@ swig_varlink_setattr(PyObject *o, char *n, PyObject *p) {
+ 
+ SWIGINTERN PyTypeObject*
+ swig_varlink_type(void) {
+-  static char varlink__doc__[] = "Swig var link object";
++  static char varlink__doc__[] = "Swig variable link object";
+ #ifndef SWIG_HEAPTYPES
+   static PyTypeObject varlink_type;
+   static int type_init = 0;
+@@ -407,10 +424,13 @@ swig_varlink_type(void) {
+       0                                   /* tp_next */
+ #endif
+     };
++    PyObject *runtime_data_module = SWIG_runtime_data_module();
+     varlink_type = tmp;
+     type_init = 1;
+     if (PyType_Ready(&varlink_type) < 0)
+       return NULL;
++    if (PyModule_AddObject(runtime_data_module, "swigvarlink", (PyObject *)&varlink_type) == 0)
++      SWIG_Py_INCREF((PyObject *)&varlink_type);
+   }
+   return &varlink_type;
+ #else
+@@ -430,7 +450,11 @@ swig_varlink_type(void) {
+     Py_TPFLAGS_DEFAULT,
+     slots
+   };
+-  return (PyTypeObject *)PyType_FromSpec(&spec);
++  PyObject *pytype = PyType_FromSpec(&spec);
++  PyObject *runtime_data_module = SWIG_runtime_data_module();
++  if (pytype && PyModule_AddObject(runtime_data_module, "swigvarlink", pytype) == 0)
++    SWIG_Py_INCREF(pytype);
++  return (PyTypeObject *)pytype;
+ #endif
+ }
+ 
+@@ -910,7 +934,7 @@ swigobject_methods[] = {
+ 
+ SWIGRUNTIME PyTypeObject*
+ SwigPyObject_TypeOnce(void) {
+-  static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
++  static char swigobject_doc[] = "Swig object holding a C/C++ pointer";
+ #ifndef SWIG_HEAPTYPES
+   static PyNumberMethods SwigPyObject_as_number = {
+     (binaryfunc)0, /*nb_add*/
+@@ -1043,10 +1067,13 @@ SwigPyObject_TypeOnce(void) {
+       0                                     /* tp_next */
+ #endif
+     };
++    PyObject *runtime_data_module = SWIG_runtime_data_module();
+     swigpyobject_type = tmp;
+     type_init = 1;
+     if (PyType_Ready(&swigpyobject_type) != 0)
+       return NULL;
++    if (PyModule_AddObject(runtime_data_module, "SwigPyObject", (PyObject *)&swigpyobject_type) == 0)
++      SWIG_Py_INCREF((PyObject *)&swigpyobject_type);
+   }
+   return &swigpyobject_type;
+ #else
+@@ -1067,7 +1094,11 @@ SwigPyObject_TypeOnce(void) {
+     Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+     slots
+   };
+-  return (PyTypeObject *)PyType_FromSpec(&spec);
++  PyObject *pytype = PyType_FromSpec(&spec);
++  PyObject *runtime_data_module = SWIG_runtime_data_module();
++  if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyObject", pytype) == 0)
++    SWIG_Py_INCREF(pytype);
++  return (PyTypeObject *)pytype;
+ #endif
+ }
+ 
+@@ -1150,7 +1181,7 @@ SwigPyPacked_Check(PyObject *op) {
+   PyObject *tp_name;
+ #endif
+   PyTypeObject* op_type = Py_TYPE(op);
+-  if (op_type == SwigPyPacked_TypeOnce())
++  if (op_type == SwigPyPacked_type())
+     return 1;
+ #ifdef Py_LIMITED_API
+   tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
+@@ -1176,7 +1207,7 @@ SwigPyPacked_dealloc(PyObject *v)
+ 
+ SWIGRUNTIME PyTypeObject*
+ SwigPyPacked_TypeOnce(void) {
+-  static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
++  static char swigpacked_doc[] = "Swig object holding a C/C++ function pointer";
+ #ifndef SWIG_HEAPTYPES
+   static PyTypeObject swigpypacked_type;
+   static int type_init = 0;
+@@ -1265,10 +1296,13 @@ SwigPyPacked_TypeOnce(void) {
+       0                                     /* tp_next */
+ #endif
+     };
++    PyObject *runtime_data_module = SWIG_runtime_data_module();
+     swigpypacked_type = tmp;
+     type_init = 1;
+     if (PyType_Ready(&swigpypacked_type) != 0)
+       return NULL;
++    if (PyModule_AddObject(runtime_data_module, "SwigPyPacked", (PyObject *)&swigpypacked_type) == 0)
++      SWIG_Py_INCREF((PyObject *)&swigpypacked_type);
+   }
+   return &swigpypacked_type;
+ #else
+@@ -1287,7 +1321,11 @@ SwigPyPacked_TypeOnce(void) {
+     Py_TPFLAGS_DEFAULT,
+     slots
+   };
+-  return (PyTypeObject *)PyType_FromSpec(&spec);
++  PyObject *pytype = PyType_FromSpec(&spec);
++  PyObject *runtime_data_module = SWIG_runtime_data_module();
++  if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyPacked", pytype) == 0)
++    SWIG_Py_INCREF(pytype);
++  return (PyTypeObject *)pytype;
+ #endif
+ }
+ 
+@@ -1815,6 +1853,12 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
+ }
+ 
+ 
++#if defined(SWIG_REFCNT_DEBUG)
++#define SWIG_PYOBJ_REFCNT(OBJ) fprintf(stdout, "" #OBJ " count %ld\n", (OBJ ? Py_REFCNT(OBJ) : 0))
++#else
++#define SWIG_PYOBJ_REFCNT(OBJ)
++#endif
++
+ static int interpreter_counter = 0; /* how many (sub-)interpreters are using swig_module's types */
+ 
+ SWIGRUNTIME void
+@@ -1825,7 +1869,7 @@ SWIG_Python_DestroyModule(PyObject *obj)
+   size_t i;
+   if (--interpreter_counter != 0) /* another sub-interpreter may still be using the swig_module's types */
+     return;
+-  for (i =0; i < swig_module->size; ++i) {
++  for (i = 0; i < swig_module->size; ++i) {
+     swig_type_info *ty = types[i];
+     if (ty->owndata) {
+       SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+@@ -1833,27 +1877,32 @@ SWIG_Python_DestroyModule(PyObject *obj)
+       if (data) SwigPyClientData_Del(data);
+     }
+   }
+-  SWIG_Py_DECREF(SWIG_This());
++  SWIG_Py_XDECREF(Swig_This_global);
++  SWIG_PYOBJ_REFCNT(Swig_This_global);
+   Swig_This_global = NULL;
+-  SWIG_Py_DECREF(SWIG_globals());
++
++  SWIG_Py_XDECREF(Swig_Globals_global);
++  SWIG_PYOBJ_REFCNT(Swig_Globals_global);
+   Swig_Globals_global = NULL;
+-  SWIG_Py_DECREF(SWIG_Python_TypeCache());
++
++  SWIG_Py_XDECREF(Swig_TypeCache_global);
++  SWIG_PYOBJ_REFCNT(Swig_TypeCache_global);
+   Swig_TypeCache_global = NULL;
++
++  SWIG_PYOBJ_REFCNT(Swig_Capsule_global);
+   Swig_Capsule_global = NULL;
++
++  SWIG_Py_XDECREF(Swig_runtime_data_module_global);
++  SWIG_PYOBJ_REFCNT(Swig_runtime_data_module_global);
++  Swig_runtime_data_module_global = NULL;
+ }
+ 
+ SWIGRUNTIME void
+ SWIG_Python_SetModule(swig_module_info *swig_module) {
+-#if PY_VERSION_HEX >= 0x03000000
+- /* Add a dummy module object into sys.modules */
+-  PyObject *module = PyImport_AddModule(SWIG_RUNTIME_MODULE);
+-#else
+-  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
+-  PyObject *module = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table);
+-#endif
++  PyObject *runtime_data_module = SWIG_runtime_data_module();
+   PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
+-  if (pointer && module) {
+-    if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) {
++  if (pointer && runtime_data_module) {
++    if (PyModule_AddObject(runtime_data_module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) {
+       ++interpreter_counter;
+       Swig_Capsule_global = pointer;
+     } else {
+-- 
+2.50.1
+
+
+From 53453d51ec3ca111c5c97530d8ee4c6b5184c85e Mon Sep 17 00:00:00 2001
+From: William S Fulton 
+Date: Mon, 12 May 2025 07:25:35 +0100
+Subject: [PATCH 3/5] Rename Python swigvarlink type to SwigVarLink
+
+With this type having just moved into a module, let's also
+make a change to use correct Python naming conventions for the
+name of the type.
+---
+ CHANGES.current      |  8 ++++++
+ Lib/python/pyrun.swg | 64 ++++++++++++++++++++++----------------------
+ 2 files changed, 40 insertions(+), 32 deletions(-)
+
+#diff --git a/CHANGES.current b/CHANGES.current
+#index 0bce7937f..9a2c0f5e2 100644
+#--- a/CHANGES.current
+#+++ b/CHANGES.current
+#@@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
+# Version 4.4.0 (in progress)
+# ===========================
+# 
+#+2025-05-11: wsfulton
+#+            [Python] Move the SwigPyObject, SwigPyPacked, SwigVarLink (renamed from
+#+            swigvarlink) support Python types to the SWIG runtime module (currently called
+#+            swig_runtime_data5).
+#+
+#+            Note that these affect the Python runtime implementation, so the recently bumped
+#+            SWIG_RUNTIME_VERSION to 5 for all scripting languages will now include this change.
+#+
+# 2025-05-10: jschueller, wsfulton
+#             [Python] #2881 #3061 #3160 DeprecationWarning fixes when using 'python -Walways'
+#             or if using one of the types being warned about:
+diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
+index 2ef79f348..e7164725d 100644
+--- a/Lib/python/pyrun.swg
++++ b/Lib/python/pyrun.swg
+@@ -257,7 +257,7 @@ typedef struct swig_varlinkobject {
+ } swig_varlinkobject;
+ 
+ SWIGINTERN PyObject *
+-swig_varlink_repr(PyObject *SWIGUNUSEDPARM(v)) {
++SwigVarLink_repr(PyObject *SWIGUNUSEDPARM(v)) {
+ #if PY_VERSION_HEX >= 0x03000000
+   return PyUnicode_InternFromString("");
+ #else
+@@ -266,7 +266,7 @@ swig_varlink_repr(PyObject *SWIGUNUSEDPARM(v)) {
+ }
+ 
+ SWIGINTERN PyObject *
+-swig_varlink_str(PyObject *o) {
++SwigVarLink_str(PyObject *o) {
+   swig_varlinkobject *v = (swig_varlinkobject *) o;
+ #if PY_VERSION_HEX >= 0x03000000
+   PyObject *str = PyUnicode_InternFromString("(");
+@@ -305,7 +305,7 @@ swig_varlink_str(PyObject *o) {
+ }
+ 
+ SWIGINTERN void
+-swig_varlink_dealloc(PyObject *o) {
++SwigVarLink_dealloc(PyObject *o) {
+   swig_varlinkobject *v = (swig_varlinkobject *) o;
+   swig_globalvar *var = v->vars;
+   while (var) {
+@@ -317,7 +317,7 @@ swig_varlink_dealloc(PyObject *o) {
+ }
+ 
+ SWIGINTERN PyObject *
+-swig_varlink_getattr(PyObject *o, char *n) {
++SwigVarLink_getattr(PyObject *o, char *n) {
+   swig_varlinkobject *v = (swig_varlinkobject *) o;
+   PyObject *res = NULL;
+   swig_globalvar *var = v->vars;
+@@ -335,7 +335,7 @@ swig_varlink_getattr(PyObject *o, char *n) {
+ }
+ 
+ SWIGINTERN int
+-swig_varlink_setattr(PyObject *o, char *n, PyObject *p) {
++SwigVarLink_setattr(PyObject *o, char *n, PyObject *p) {
+   swig_varlinkobject *v = (swig_varlinkobject *) o;
+   int res = 1;
+   swig_globalvar *var = v->vars;
+@@ -358,7 +358,7 @@ swig_varlink_setattr(PyObject *o, char *n, PyObject *p) {
+ 
+ SWIGINTERN PyTypeObject*
+ swig_varlink_type(void) {
+-  static char varlink__doc__[] = "Swig variable link object";
++  static char SwigVarLink_doc[] = "Swig variable link object";
+ #ifndef SWIG_HEAPTYPES
+   static PyTypeObject varlink_type;
+   static int type_init = 0;
+@@ -370,30 +370,30 @@ swig_varlink_type(void) {
+       PyObject_HEAD_INIT(NULL)
+       0,                                  /* ob_size */
+ #endif
+-      SWIG_RUNTIME_MODULE ".swigvarlink", /* tp_name */
++      SWIG_RUNTIME_MODULE ".SwigVarLink", /* tp_name */
+       sizeof(swig_varlinkobject),         /* tp_basicsize */
+       0,                                  /* tp_itemsize */
+-      (destructor) swig_varlink_dealloc,  /* tp_dealloc */
++      (destructor) SwigVarLink_dealloc,   /* tp_dealloc */
+ #if PY_VERSION_HEX < 0x030800b4
+       (printfunc)0,                       /* tp_print */
+ #else
+       (Py_ssize_t)0,                      /* tp_vectorcall_offset */
+ #endif
+-      (getattrfunc) swig_varlink_getattr, /* tp_getattr */
+-      (setattrfunc) swig_varlink_setattr, /* tp_setattr */
++      (getattrfunc) SwigVarLink_getattr,  /* tp_getattr */
++      (setattrfunc) SwigVarLink_setattr,  /* tp_setattr */
+       0,                                  /* tp_compare */
+-      (reprfunc) swig_varlink_repr,       /* tp_repr */
++      (reprfunc) SwigVarLink_repr,        /* tp_repr */
+       0,                                  /* tp_as_number */
+       0,                                  /* tp_as_sequence */
+       0,                                  /* tp_as_mapping */
+       0,                                  /* tp_hash */
+       0,                                  /* tp_call */
+-      (reprfunc) swig_varlink_str,        /* tp_str */
++      (reprfunc) SwigVarLink_str,         /* tp_str */
+       0,                                  /* tp_getattro */
+       0,                                  /* tp_setattro */
+       0,                                  /* tp_as_buffer */
+       0,                                  /* tp_flags */
+-      varlink__doc__,                     /* tp_doc */
++      SwigVarLink_doc,                    /* tp_doc */
+       0,                                  /* tp_traverse */
+       0,                                  /* tp_clear */
+       0,                                  /* tp_richcompare */
+@@ -429,22 +429,22 @@ swig_varlink_type(void) {
+     type_init = 1;
+     if (PyType_Ready(&varlink_type) < 0)
+       return NULL;
+-    if (PyModule_AddObject(runtime_data_module, "swigvarlink", (PyObject *)&varlink_type) == 0)
++    if (PyModule_AddObject(runtime_data_module, "SwigVarLink", (PyObject *)&varlink_type) == 0)
+       SWIG_Py_INCREF((PyObject *)&varlink_type);
+   }
+   return &varlink_type;
+ #else
+   PyType_Slot slots[] = {
+-    { Py_tp_dealloc, (void *)swig_varlink_dealloc },
+-    { Py_tp_repr, (void *)swig_varlink_repr },
+-    { Py_tp_getattr, (void *)swig_varlink_getattr },
+-    { Py_tp_setattr, (void *)swig_varlink_setattr },
+-    { Py_tp_str, (void *)swig_varlink_str },
+-    { Py_tp_doc, (void *)varlink__doc__ },
++    { Py_tp_dealloc, (void *)SwigVarLink_dealloc },
++    { Py_tp_repr, (void *)SwigVarLink_repr },
++    { Py_tp_getattr, (void *)SwigVarLink_getattr },
++    { Py_tp_setattr, (void *)SwigVarLink_setattr },
++    { Py_tp_str, (void *)SwigVarLink_str },
++    { Py_tp_doc, (void *)SwigVarLink_doc },
+     { 0, NULL }
+   };
+   PyType_Spec spec = {
+-    SWIG_RUNTIME_MODULE ".swigvarlink",
++    SWIG_RUNTIME_MODULE ".SwigVarLink",
+     sizeof(swig_varlinkobject),
+     0,
+     Py_TPFLAGS_DEFAULT,
+@@ -452,7 +452,7 @@ swig_varlink_type(void) {
+   };
+   PyObject *pytype = PyType_FromSpec(&spec);
+   PyObject *runtime_data_module = SWIG_runtime_data_module();
+-  if (pytype && PyModule_AddObject(runtime_data_module, "swigvarlink", pytype) == 0)
++  if (pytype && PyModule_AddObject(runtime_data_module, "SwigVarLink", pytype) == 0)
+     SWIG_Py_INCREF(pytype);
+   return (PyTypeObject *)pytype;
+ #endif
+@@ -715,7 +715,7 @@ SwigPyObject_repr(SwigPyObject *v)
+ }
+ 
+ /* We need a version taking two PyObject* parameters so it's a valid
+- * PyCFunction to use in swigobject_methods[]. */
++ * PyCFunction to use in SwigPyObject_methods[]. */
+ SWIGRUNTIME PyObject *
+ SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
+ {
+@@ -922,7 +922,7 @@ SwigPyObject_own(PyObject *v, PyObject *args)
+ }
+ 
+ static PyMethodDef
+-swigobject_methods[] = {
++SwigPyObject_methods[] = {
+   {"disown",  SwigPyObject_disown,  METH_NOARGS,  "releases ownership of the pointer"},
+   {"acquire", SwigPyObject_acquire, METH_NOARGS,  "acquires ownership of the pointer"},
+   {"own",     SwigPyObject_own,     METH_VARARGS, "returns/sets ownership of the pointer"},
+@@ -934,7 +934,7 @@ swigobject_methods[] = {
+ 
+ SWIGRUNTIME PyTypeObject*
+ SwigPyObject_TypeOnce(void) {
+-  static char swigobject_doc[] = "Swig object holding a C/C++ pointer";
++  static char SwigPyObject_doc[] = "Swig object holding a C/C++ pointer";
+ #ifndef SWIG_HEAPTYPES
+   static PyNumberMethods SwigPyObject_as_number = {
+     (binaryfunc)0, /*nb_add*/
+@@ -1017,14 +1017,14 @@ SwigPyObject_TypeOnce(void) {
+       0,                                    /* tp_setattro */
+       0,                                    /* tp_as_buffer */
+       Py_TPFLAGS_DEFAULT,                   /* tp_flags */
+-      swigobject_doc,                       /* tp_doc */
++      SwigPyObject_doc,                     /* tp_doc */
+       0,                                    /* tp_traverse */
+       0,                                    /* tp_clear */
+       (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
+       0,                                    /* tp_weaklistoffset */
+       0,                                    /* tp_iter */
+       0,                                    /* tp_iternext */
+-      swigobject_methods,                   /* tp_methods */
++      SwigPyObject_methods,                 /* tp_methods */
+       0,                                    /* tp_members */
+       0,                                    /* tp_getset */
+       0,                                    /* tp_base */
+@@ -1081,9 +1081,9 @@ SwigPyObject_TypeOnce(void) {
+     { Py_tp_dealloc, (void *)SwigPyObject_dealloc },
+     { Py_tp_repr, (void *)SwigPyObject_repr },
+     { Py_tp_getattro, (void *)PyObject_GenericGetAttr },
+-    { Py_tp_doc, (void *)swigobject_doc },
++    { Py_tp_doc, (void *)SwigPyObject_doc },
+     { Py_tp_richcompare, (void *)SwigPyObject_richcompare },
+-    { Py_tp_methods, (void *)swigobject_methods },
++    { Py_tp_methods, (void *)SwigPyObject_methods },
+     { Py_nb_int, (void *)SwigPyObject_long },
+     { 0, NULL }
+   };
+@@ -1207,7 +1207,7 @@ SwigPyPacked_dealloc(PyObject *v)
+ 
+ SWIGRUNTIME PyTypeObject*
+ SwigPyPacked_TypeOnce(void) {
+-  static char swigpacked_doc[] = "Swig object holding a C/C++ function pointer";
++  static char SwigPyPacked_doc[] = "Swig object holding a C/C++ function pointer";
+ #ifndef SWIG_HEAPTYPES
+   static PyTypeObject swigpypacked_type;
+   static int type_init = 0;
+@@ -1246,7 +1246,7 @@ SwigPyPacked_TypeOnce(void) {
+       0,                                    /* tp_setattro */
+       0,                                    /* tp_as_buffer */
+       Py_TPFLAGS_DEFAULT,                   /* tp_flags */
+-      swigpacked_doc,                       /* tp_doc */
++      SwigPyPacked_doc,                     /* tp_doc */
+       0,                                    /* tp_traverse */
+       0,                                    /* tp_clear */
+       0,                                    /* tp_richcompare */
+@@ -1311,7 +1311,7 @@ SwigPyPacked_TypeOnce(void) {
+     { Py_tp_repr, (void *)SwigPyPacked_repr },
+     { Py_tp_str, (void *)SwigPyPacked_str },
+     { Py_tp_getattro, (void *)PyObject_GenericGetAttr },
+-    { Py_tp_doc, (void *)swigpacked_doc },
++    { Py_tp_doc, (void *)SwigPyPacked_doc },
+     { 0, NULL }
+   };
+   PyType_Spec spec = {
+-- 
+2.50.1
+
+
+From 831fc6069115b8a31bed5d0bcae221825cd43c18 Mon Sep 17 00:00:00 2001
+From: William S Fulton 
+Date: Tue, 13 May 2025 08:40:45 +0100
+Subject: [PATCH 4/5] Add docs on the python runtime module
+
+---
+ Doc/Manual/Python.html | 50 ++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 50 insertions(+)
+
+diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
+index 7427ca4cf..cc82e9762 100644
+--- a/Doc/Manual/Python.html
++++ b/Doc/Manual/Python.html
+@@ -1000,6 +1000,10 @@ module name, make sure you don't use the same name as a built-in
+ Python command or standard module name.
+ 

+ ++

++There is also a further 'behind the scenes' Python runtime module, but this implementation detail is covered later. ++

++ +

33.3.2 Functions

+ + +@@ -2704,6 +2708,52 @@ in the file python/pyopers.swg in the SWIG library. +

+ + ++

33.4.3 Python runtime module

++ ++

++In addition to the two Python modules that are generated by SWIG, there is also a third 'behind the scenes' Python runtime module. ++The runtime module is very much an implementation level detail, but is mentioned here for completeness and for the inquisitive! ++

++ ++

++SWIG implements a run-time type checker for checking a Python type/class as it passes between the Python and C/C++ layers. ++It is also used when multiple SWIG modules need to share type information with each other (when using the %import directive). ++More details can be found in the SWIG runtime code and run-time type checker sections. ++The runtime module contains the following: ++

++ ++
    ++
  1. A Python Capsule containing a pointer to the underlying C module data structure used by the runtime type checker. For multiple modules to access the common runtime implementation. The Capsule is named type_pointer_capsule except when using -builtin when it is instead called type_pointer_capsule_builtin.
  2. ++
  3. The builtin type SwigPyObject - Swig object holding a C/C++ pointer. For 'normal' pointers, that is, not for function pointers nor member function pointers.
  4. ++
  5. The builtin type SwigPyPacked - Swig object holding a C/C++ function pointer. For C pointers to a function or C++ member function pointers.
  6. ++
  7. The builtin type SwigVarLink - Swig variable link object. The type used by the 'cvar' field for accessing C/C++ global variables.
  8. ++
++ ++

++If multiple SWIG modules are being used, the C/C++ wrapped proxy classes/types can be shared or used across the different modules via the SWIG runtime. ++The runtime is accessed and shared via the Capsule in the runtime module. ++The Python runtime module is implemented as a Python builtin module. While users are unlikely to use or import the runtime module directly, it can be inspected simply enough. ++The name of the module is swig_runtime_data appended with the runtime version as defined by SWIG_RUNTIME_VERSION. ++First import your SWIG generated module. Next find the exact runtime module name so you know what to import before inspecting it with say dir. ++The interpreter session below demonstrates this with a SWIG generated module called example: ++

++ ++
++
++>>> import example
++>>> import sys
++>>> list(m for m in sys.modules if m.startswith("swig_runtime_data"))
++['swig_runtime_data5']
++>>> import swig_runtime_data5
++>>> dir(swig_runtime_data5)
++['SwigPyObject', 'SwigPyPacked', 'SwigVarLink', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'type_pointer_capsule']
++
++
++ ++

++Compatibility Note: Only the Capsule was stored in the Python runtime module prior to SWIG-4.4.0. ++

++ +

33.4.3 Memory management

+ + +-- +2.50.1 + + +From d966fd3ba18370b5bf34b67ff376d88fb6d3e65b Mon Sep 17 00:00:00 2001 +From: William S Fulton +Date: Tue, 13 May 2025 21:42:56 +0100 +Subject: [PATCH 5/5] Test swig runtime module contains expected names + +--- + .../python/python_moduleimport_runme.py | 17 +++++++++++++++++ + Examples/test-suite/python_moduleimport.i | 2 ++ + 2 files changed, 19 insertions(+) + +diff --git a/Examples/test-suite/python/python_moduleimport_runme.py b/Examples/test-suite/python/python_moduleimport_runme.py +index cdb860730..8e0aa6121 100644 +--- a/Examples/test-suite/python/python_moduleimport_runme.py ++++ b/Examples/test-suite/python/python_moduleimport_runme.py +@@ -1,7 +1,24 @@ + import python_moduleimport + ++# Test custom moduleimport in %module + if python_moduleimport.simple_function(99) != 99: + raise RuntimeError("simple_function") + + if python_moduleimport.extra_import_variable != "custom import of _python_moduleimport": + raise RuntimeError("custom import") ++ ++ ++# Test the swig runtime module contains the expected names/types ++import importlib ++swig_runtime_version = python_moduleimport.runtime_version() ++swig_runtime_data = importlib.import_module("swig_runtime_data" + swig_runtime_version) # Equivalent to (for version 5): import swig_runtime_data5 as swig_runtime_data ++ ++names = dir(swig_runtime_data) ++expected_names = ("SwigPyObject", "SwigPyPacked", "SwigVarLink") ++for name in expected_names: ++ if name not in names: ++ raise RuntimeError("{} not in {}".format(name, names)) ++ ++cvar_type = type(python_moduleimport.cvar) ++if cvar_type.__name__ != "SwigVarLink": ++ raise RuntimeError("cvar type name is incorrect: {}".format(cvar_type.__name__)) +diff --git a/Examples/test-suite/python_moduleimport.i b/Examples/test-suite/python_moduleimport.i +index f62547dcd..f0d203433 100644 +--- a/Examples/test-suite/python_moduleimport.i ++++ b/Examples/test-suite/python_moduleimport.i +@@ -23,4 +23,6 @@ from $module import * + + %inline %{ + int simple_function(int i) { return i; } ++int globalvar = 99; ++const char * runtime_version() { return SWIG_RUNTIME_VERSION; } + %} +-- +2.50.1 + diff --git a/swig.spec b/swig.spec index 9c690f1..7aa16c3 100644 --- a/swig.spec +++ b/swig.spec @@ -69,7 +69,7 @@ Summary: Connects C/C++/Objective C to some high-level programming languages Name: swig Version: 4.3.1 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL-3.0-or-later AND BSD-3-Clause URL: https://www.swig.org/ Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz @@ -82,6 +82,9 @@ Source4: ccache-swig.csh %endif # https://github.com/swig/swig/pull/3159 Patch0: swig-python-Python-3.14-support.patch +# Python DeprecationWarning fixes - in upstream after 4.4.0 +# https://github.com/swig/swig/issues/2881 +Patch1: swig-4.4.0-Python-DeprecationWarning-fixes.patch BuildRequires: coreutils BuildRequires: findutils @@ -365,6 +368,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb %{_datadir}/%{name}/gdb %changelog +* Thu Jul 31 2025 Jitka Plesnikova - 4.3.1-4 +- Fix Python DeprecationWarning + * Fri Jul 25 2025 Fedora Release Engineering - 4.3.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild From ad62c005a3acb8b4cd79580fd0d8e6f7051f5f2c Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 7 Aug 2025 10:42:08 -0600 Subject: [PATCH 4/7] Rebuild for Octave 10.2 --- swig.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/swig.spec b/swig.spec index 7aa16c3..4861e11 100644 --- a/swig.spec +++ b/swig.spec @@ -69,7 +69,7 @@ Summary: Connects C/C++/Objective C to some high-level programming languages Name: swig Version: 4.3.1 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL-3.0-or-later AND BSD-3-Clause URL: https://www.swig.org/ Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz @@ -368,6 +368,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb %{_datadir}/%{name}/gdb %changelog +* Thu Aug 07 2025 Orion Poplawski - 4.3.1-5 +- Rebuild for Octave 10.2 + * Thu Jul 31 2025 Jitka Plesnikova - 4.3.1-4 - Fix Python DeprecationWarning From 28a355063e5bef532843d6e332ee5e2a6da050fd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 13 Oct 2025 18:22:54 +0100 Subject: [PATCH 5/7] OCaml 5.4.0 rebuild --- swig.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/swig.spec b/swig.spec index 4861e11..d60b620 100644 --- a/swig.spec +++ b/swig.spec @@ -69,7 +69,7 @@ Summary: Connects C/C++/Objective C to some high-level programming languages Name: swig Version: 4.3.1 -Release: 5%{?dist} +Release: 6%{?dist} License: GPL-3.0-or-later AND BSD-3-Clause URL: https://www.swig.org/ Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz @@ -368,6 +368,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb %{_datadir}/%{name}/gdb %changelog +* Mon Oct 13 2025 Richard W.M. Jones - 4.3.1-6 +- OCaml 5.4.0 rebuild + * Thu Aug 07 2025 Orion Poplawski - 4.3.1-5 - Rebuild for Octave 10.2 From 6eb1208d37dd0ce6bd8cf17f8877154879b1853e Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Thu, 23 Oct 2025 12:20:59 +0200 Subject: [PATCH 6/7] 4.4.0 bump (rhbz#2405182) --- .gitignore | 1 + sources | 2 +- swig.spec | 14 ++++++-------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 34ba3f1..a1b574c 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ swig-2.0.0.tar.gz /swig-4.2.1.tar.gz /swig-4.3.0.tar.gz /swig-4.3.1.tar.gz +/swig-4.4.0.tar.gz diff --git a/sources b/sources index 581ec8f..06c0ef9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (swig-4.3.1.tar.gz) = 8958f7bc3345549a9bc4e00aa8d40a99f6c4bb92b95d627c8796cf8f8d1ba0041a89cab542f171778c2b26aa2a877767181ae9bd2c05fd055f373a32a463399c +SHA512 (swig-4.4.0.tar.gz) = 0cd4625166240f73075c22e140336b8e39f0f98d4343caba472b8eb3fa64561152e6978d5735d883cf62af10b84a9f0e20b3bb40288341a82c68a4cb79e46f5f diff --git a/swig.spec b/swig.spec index 7aa16c3..30cbcc9 100644 --- a/swig.spec +++ b/swig.spec @@ -56,7 +56,7 @@ %else # Temporary disable java tests, because they doesn't pass with java-21-openjdk # https://github.com/swig/swig/issues/2767 -%{!?javalang:%global javalang 0} +%{!?javalang:%global javalang 1} %endif # Do not run Go tests, they failed with 4.0.0 on ppc64le, s390 @@ -68,8 +68,8 @@ Summary: Connects C/C++/Objective C to some high-level programming languages Name: swig -Version: 4.3.1 -Release: 4%{?dist} +Version: 4.4.0 +Release: 1%{?dist} License: GPL-3.0-or-later AND BSD-3-Clause URL: https://www.swig.org/ Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz @@ -80,11 +80,6 @@ Source2: description-ccache.h2m Source3: ccache-swig.sh Source4: ccache-swig.csh %endif -# https://github.com/swig/swig/pull/3159 -Patch0: swig-python-Python-3.14-support.patch -# Python DeprecationWarning fixes - in upstream after 4.4.0 -# https://github.com/swig/swig/issues/2881 -Patch1: swig-4.4.0-Python-DeprecationWarning-fixes.patch BuildRequires: coreutils BuildRequires: findutils @@ -368,6 +363,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb %{_datadir}/%{name}/gdb %changelog +* Tue Oct 21 2025 Jitka Plesnikova - 4.4.0-1 +- 4.4.0 bump (rhbz#2405182) + * Thu Jul 31 2025 Jitka Plesnikova - 4.3.1-4 - Fix Python DeprecationWarning From 74b108992c47cd36a336557f97c70fd5aed0dbf3 Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Wed, 10 Dec 2025 15:58:52 +0100 Subject: [PATCH 7/7] 4.4.1 bump (rhbz#2419819, rhbz#2415440) --- .gitignore | 1 + sources | 2 +- ....4.0-Python-DeprecationWarning-fixes.patch | 806 ------------------ swig.spec | 5 +- 4 files changed, 6 insertions(+), 808 deletions(-) delete mode 100644 swig-4.4.0-Python-DeprecationWarning-fixes.patch diff --git a/.gitignore b/.gitignore index a1b574c..8cec1dc 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ swig-2.0.0.tar.gz /swig-4.3.0.tar.gz /swig-4.3.1.tar.gz /swig-4.4.0.tar.gz +/swig-4.4.1.tar.gz diff --git a/sources b/sources index 06c0ef9..f6fe3ce 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (swig-4.4.0.tar.gz) = 0cd4625166240f73075c22e140336b8e39f0f98d4343caba472b8eb3fa64561152e6978d5735d883cf62af10b84a9f0e20b3bb40288341a82c68a4cb79e46f5f +SHA512 (swig-4.4.1.tar.gz) = 103ddb4a5914f28e6739a006d35042c701e55ba05066acff3f3609befb5f43f253ea717fc41d06c93d8fb187ded4399c12c94665b93dc06d0fb835069391c7c7 diff --git a/swig-4.4.0-Python-DeprecationWarning-fixes.patch b/swig-4.4.0-Python-DeprecationWarning-fixes.patch deleted file mode 100644 index 17b9246..0000000 --- a/swig-4.4.0-Python-DeprecationWarning-fixes.patch +++ /dev/null @@ -1,806 +0,0 @@ -From 49a7d2b0c6aed00bd07a9a28569020d560c2658c Mon Sep 17 00:00:00 2001 -From: William S Fulton -Date: Sat, 10 May 2025 13:47:35 +0100 -Subject: [PATCH 1/5] Python DeprecationWarning fixes - -DeprecationWarning fixes when using 'python -Walways' or if using one of the types being warned about: - - DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute - DeprecationWarning: builtin type SwigPyObject has no __module__ attribute - DeprecationWarning: builtin type swigvarlink has no __module__ attribute - -The warning was present if code was generated without using -builtin in 4.3.x. -The warning was only present if using the Python limited API in 4.2.1 and earlier. - -These 3 types were not in any module at all. Now they are in the swig runtime module. -Docs to follow. - -Issue #2881 -Issue #3061 -Issue #3160 ---- - CHANGES.current | 11 +++++++++++ - Lib/python/pyhead.swg | 4 +++- - Lib/python/pyrun.swg | 22 +++++++++++----------- - 3 files changed, 25 insertions(+), 12 deletions(-) - -#diff --git a/CHANGES.current b/CHANGES.current -#index 99c8a1d8f..0bce7937f 100644 -#--- a/CHANGES.current -#+++ b/CHANGES.current -#@@ -7,6 +7,17 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ -# Version 4.4.0 (in progress) -# =========================== -# -#+2025-05-10: jschueller, wsfulton -#+ [Python] #2881 #3061 #3160 DeprecationWarning fixes when using 'python -Walways' -#+ or if using one of the types being warned about: -#+ -#+ DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute -#+ DeprecationWarning: builtin type SwigPyObject has no __module__ attribute -#+ DeprecationWarning: builtin type swigvarlink has no __module__ attribute -#+ -#+ The warning was present if code was generated without using -builtin in 4.3.x. -#+ The warning was only present if using the Python limited API in 4.2.1 and earlier. -#+ -# 2025-04-30: wsfulton -# [Python] #3134 Fix maximum size of strings being marshalled from C/C++ -# into Python. This has been changed from INT_MAX to PY_SSIZE_T_MAX in line -diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg -index 50dca5bc0..4f238b9f6 100644 ---- a/Lib/python/pyhead.swg -+++ b/Lib/python/pyhead.swg -@@ -60,6 +60,8 @@ SWIG_Python_str_FromChar(const char *c) - #endif - } - -+#define SWIG_RUNTIME_MODULE "swig_runtime_data" SWIG_RUNTIME_VERSION -+ - /* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */ - # define SWIGPY_USE_CAPSULE - #ifdef SWIGPYTHON_BUILTIN -@@ -67,7 +69,7 @@ SWIG_Python_str_FromChar(const char *c) - #else - # define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule" SWIG_TYPE_TABLE_NAME - #endif --# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION "." SWIGPY_CAPSULE_ATTR_NAME) -+#define SWIGPY_CAPSULE_NAME SWIG_RUNTIME_MODULE "." SWIGPY_CAPSULE_ATTR_NAME - - #if PY_VERSION_HEX < 0x03020000 - #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) -diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg -index 77d7fccfa..b9e3e7241 100644 ---- a/Lib/python/pyrun.swg -+++ b/Lib/python/pyrun.swg -@@ -353,7 +353,7 @@ swig_varlink_type(void) { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - #endif -- "swigvarlink", /* tp_name */ -+ SWIG_RUNTIME_MODULE ".swigvarlink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) swig_varlink_dealloc, /* tp_dealloc */ -@@ -424,7 +424,7 @@ swig_varlink_type(void) { - { 0, NULL } - }; - PyType_Spec spec = { -- "swigvarlink", -+ SWIG_RUNTIME_MODULE ".swigvarlink", - sizeof(swig_varlinkobject), - 0, - Py_TPFLAGS_DEFAULT, -@@ -750,7 +750,7 @@ SwigPyObject_Check(PyObject *op) { - #ifdef SWIGPYTHON_BUILTIN - if (PyType_IsSubtype(op_type, target_tp)) - return 1; -- return (strcmp(op_type->tp_name, "SwigPyObject") == 0); -+ return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0); - #else - # ifdef Py_LIMITED_API - int cmp; -@@ -766,7 +766,7 @@ SwigPyObject_Check(PyObject *op) { - SWIG_Py_DECREF(tp_name); - return cmp == 0; - # else -- return (strcmp(op_type->tp_name, "SwigPyObject") == 0); -+ return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0); - # endif - #endif - } -@@ -966,7 +966,7 @@ SwigPyObject_TypeOnce(void) { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - #endif -- "SwigPyObject", /* tp_name */ -+ SWIG_RUNTIME_MODULE ".SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ -@@ -1061,7 +1061,7 @@ SwigPyObject_TypeOnce(void) { - { 0, NULL } - }; - PyType_Spec spec = { -- "SwigPyObject", -+ SWIG_RUNTIME_MODULE ".SwigPyObject", - sizeof(SwigPyObject), - 0, - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, -@@ -1160,7 +1160,7 @@ SwigPyPacked_Check(PyObject *op) { - SWIG_Py_DECREF(tp_name); - return cmp == 0; - #else -- return (strcmp(op_type->tp_name, "SwigPyPacked") == 0); -+ return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyPacked") == 0); - #endif - } - -@@ -1188,7 +1188,7 @@ SwigPyPacked_TypeOnce(void) { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - #endif -- "SwigPyPacked", /* tp_name */ -+ SWIG_RUNTIME_MODULE ".SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ -@@ -1281,7 +1281,7 @@ SwigPyPacked_TypeOnce(void) { - { 0, NULL } - }; - PyType_Spec spec = { -- "SwigPyPacked", -+ SWIG_RUNTIME_MODULE ".SwigPyPacked", - sizeof(SwigPyPacked), - 0, - Py_TPFLAGS_DEFAULT, -@@ -1846,10 +1846,10 @@ SWIGRUNTIME void - SWIG_Python_SetModule(swig_module_info *swig_module) { - #if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ -- PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); -+ PyObject *module = PyImport_AddModule(SWIG_RUNTIME_MODULE); - #else - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ -- PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); -+ PyObject *module = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table); - #endif - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); - if (pointer && module) { --- -2.50.1 - - -From 7ecbb7103dec48bb316baa9ccd71ba7888de7c54 Mon Sep 17 00:00:00 2001 -From: William S Fulton -Date: Sun, 11 May 2025 16:02:43 +0100 -Subject: [PATCH 2/5] Add SwigPyObject, SwigPyPacked, swigvarlink to the swig - runtime module - -Also add SWIG_REFCNT_DEBUG for debugging reference counts when the main -module is destroyed - there's some work to be done here on reference -counts! ---- - Lib/python/pyinit.swg | 1 + - Lib/python/pyrun.swg | 91 +++++++++++++++++++++++++++++++++---------- - 2 files changed, 71 insertions(+), 21 deletions(-) - -diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg -index 5bf7097f5..4e25323f6 100644 ---- a/Lib/python/pyinit.swg -+++ b/Lib/python/pyinit.swg -@@ -261,6 +261,7 @@ SWIG_init(void) { - (void)globals; - - /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ -+ SWIG_runtime_data_module(); - SWIG_This(); - SWIG_Python_TypeCache(); - SwigPyPacked_type(); -diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg -index b9e3e7241..2ef79f348 100644 ---- a/Lib/python/pyrun.swg -+++ b/Lib/python/pyrun.swg -@@ -114,8 +114,25 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - - #endif - --/* Append a value to the result obj */ -+/* SWIG runtime data Python module */ -+static PyObject *Swig_runtime_data_module_global = NULL; -+ -+/* Create/obtain the single swig_runtime_data module which is used across different SWIG generated modules */ -+SWIGINTERN PyObject * -+SWIG_runtime_data_module() { -+ if (!Swig_runtime_data_module_global) { -+#if PY_VERSION_HEX >= 0x03000000 -+ Swig_runtime_data_module_global = PyImport_AddModule(SWIG_RUNTIME_MODULE); -+#else -+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ -+ Swig_runtime_data_module_global = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table); -+#endif -+ SWIG_Py_XINCREF(Swig_runtime_data_module_global); -+ } -+ return Swig_runtime_data_module_global; -+} - -+/* Append a value to the result obj */ - SWIGINTERN PyObject* - SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void) { - if (!result) { -@@ -341,7 +358,7 @@ swig_varlink_setattr(PyObject *o, char *n, PyObject *p) { - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { -- static char varlink__doc__[] = "Swig var link object"; -+ static char varlink__doc__[] = "Swig variable link object"; - #ifndef SWIG_HEAPTYPES - static PyTypeObject varlink_type; - static int type_init = 0; -@@ -407,10 +424,13 @@ swig_varlink_type(void) { - 0 /* tp_next */ - #endif - }; -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); - varlink_type = tmp; - type_init = 1; - if (PyType_Ready(&varlink_type) < 0) - return NULL; -+ if (PyModule_AddObject(runtime_data_module, "swigvarlink", (PyObject *)&varlink_type) == 0) -+ SWIG_Py_INCREF((PyObject *)&varlink_type); - } - return &varlink_type; - #else -@@ -430,7 +450,11 @@ swig_varlink_type(void) { - Py_TPFLAGS_DEFAULT, - slots - }; -- return (PyTypeObject *)PyType_FromSpec(&spec); -+ PyObject *pytype = PyType_FromSpec(&spec); -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); -+ if (pytype && PyModule_AddObject(runtime_data_module, "swigvarlink", pytype) == 0) -+ SWIG_Py_INCREF(pytype); -+ return (PyTypeObject *)pytype; - #endif - } - -@@ -910,7 +934,7 @@ swigobject_methods[] = { - - SWIGRUNTIME PyTypeObject* - SwigPyObject_TypeOnce(void) { -- static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; -+ static char swigobject_doc[] = "Swig object holding a C/C++ pointer"; - #ifndef SWIG_HEAPTYPES - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ -@@ -1043,10 +1067,13 @@ SwigPyObject_TypeOnce(void) { - 0 /* tp_next */ - #endif - }; -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); - swigpyobject_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpyobject_type) != 0) - return NULL; -+ if (PyModule_AddObject(runtime_data_module, "SwigPyObject", (PyObject *)&swigpyobject_type) == 0) -+ SWIG_Py_INCREF((PyObject *)&swigpyobject_type); - } - return &swigpyobject_type; - #else -@@ -1067,7 +1094,11 @@ SwigPyObject_TypeOnce(void) { - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, - slots - }; -- return (PyTypeObject *)PyType_FromSpec(&spec); -+ PyObject *pytype = PyType_FromSpec(&spec); -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); -+ if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyObject", pytype) == 0) -+ SWIG_Py_INCREF(pytype); -+ return (PyTypeObject *)pytype; - #endif - } - -@@ -1150,7 +1181,7 @@ SwigPyPacked_Check(PyObject *op) { - PyObject *tp_name; - #endif - PyTypeObject* op_type = Py_TYPE(op); -- if (op_type == SwigPyPacked_TypeOnce()) -+ if (op_type == SwigPyPacked_type()) - return 1; - #ifdef Py_LIMITED_API - tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); -@@ -1176,7 +1207,7 @@ SwigPyPacked_dealloc(PyObject *v) - - SWIGRUNTIME PyTypeObject* - SwigPyPacked_TypeOnce(void) { -- static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; -+ static char swigpacked_doc[] = "Swig object holding a C/C++ function pointer"; - #ifndef SWIG_HEAPTYPES - static PyTypeObject swigpypacked_type; - static int type_init = 0; -@@ -1265,10 +1296,13 @@ SwigPyPacked_TypeOnce(void) { - 0 /* tp_next */ - #endif - }; -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); - swigpypacked_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpypacked_type) != 0) - return NULL; -+ if (PyModule_AddObject(runtime_data_module, "SwigPyPacked", (PyObject *)&swigpypacked_type) == 0) -+ SWIG_Py_INCREF((PyObject *)&swigpypacked_type); - } - return &swigpypacked_type; - #else -@@ -1287,7 +1321,11 @@ SwigPyPacked_TypeOnce(void) { - Py_TPFLAGS_DEFAULT, - slots - }; -- return (PyTypeObject *)PyType_FromSpec(&spec); -+ PyObject *pytype = PyType_FromSpec(&spec); -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); -+ if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyPacked", pytype) == 0) -+ SWIG_Py_INCREF(pytype); -+ return (PyTypeObject *)pytype; - #endif - } - -@@ -1815,6 +1853,12 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { - } - - -+#if defined(SWIG_REFCNT_DEBUG) -+#define SWIG_PYOBJ_REFCNT(OBJ) fprintf(stdout, "" #OBJ " count %ld\n", (OBJ ? Py_REFCNT(OBJ) : 0)) -+#else -+#define SWIG_PYOBJ_REFCNT(OBJ) -+#endif -+ - static int interpreter_counter = 0; /* how many (sub-)interpreters are using swig_module's types */ - - SWIGRUNTIME void -@@ -1825,7 +1869,7 @@ SWIG_Python_DestroyModule(PyObject *obj) - size_t i; - if (--interpreter_counter != 0) /* another sub-interpreter may still be using the swig_module's types */ - return; -- for (i =0; i < swig_module->size; ++i) { -+ for (i = 0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; -@@ -1833,27 +1877,32 @@ SWIG_Python_DestroyModule(PyObject *obj) - if (data) SwigPyClientData_Del(data); - } - } -- SWIG_Py_DECREF(SWIG_This()); -+ SWIG_Py_XDECREF(Swig_This_global); -+ SWIG_PYOBJ_REFCNT(Swig_This_global); - Swig_This_global = NULL; -- SWIG_Py_DECREF(SWIG_globals()); -+ -+ SWIG_Py_XDECREF(Swig_Globals_global); -+ SWIG_PYOBJ_REFCNT(Swig_Globals_global); - Swig_Globals_global = NULL; -- SWIG_Py_DECREF(SWIG_Python_TypeCache()); -+ -+ SWIG_Py_XDECREF(Swig_TypeCache_global); -+ SWIG_PYOBJ_REFCNT(Swig_TypeCache_global); - Swig_TypeCache_global = NULL; -+ -+ SWIG_PYOBJ_REFCNT(Swig_Capsule_global); - Swig_Capsule_global = NULL; -+ -+ SWIG_Py_XDECREF(Swig_runtime_data_module_global); -+ SWIG_PYOBJ_REFCNT(Swig_runtime_data_module_global); -+ Swig_runtime_data_module_global = NULL; - } - - SWIGRUNTIME void - SWIG_Python_SetModule(swig_module_info *swig_module) { --#if PY_VERSION_HEX >= 0x03000000 -- /* Add a dummy module object into sys.modules */ -- PyObject *module = PyImport_AddModule(SWIG_RUNTIME_MODULE); --#else -- static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ -- PyObject *module = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table); --#endif -+ PyObject *runtime_data_module = SWIG_runtime_data_module(); - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); -- if (pointer && module) { -- if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { -+ if (pointer && runtime_data_module) { -+ if (PyModule_AddObject(runtime_data_module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { - ++interpreter_counter; - Swig_Capsule_global = pointer; - } else { --- -2.50.1 - - -From 53453d51ec3ca111c5c97530d8ee4c6b5184c85e Mon Sep 17 00:00:00 2001 -From: William S Fulton -Date: Mon, 12 May 2025 07:25:35 +0100 -Subject: [PATCH 3/5] Rename Python swigvarlink type to SwigVarLink - -With this type having just moved into a module, let's also -make a change to use correct Python naming conventions for the -name of the type. ---- - CHANGES.current | 8 ++++++ - Lib/python/pyrun.swg | 64 ++++++++++++++++++++++---------------------- - 2 files changed, 40 insertions(+), 32 deletions(-) - -#diff --git a/CHANGES.current b/CHANGES.current -#index 0bce7937f..9a2c0f5e2 100644 -#--- a/CHANGES.current -#+++ b/CHANGES.current -#@@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ -# Version 4.4.0 (in progress) -# =========================== -# -#+2025-05-11: wsfulton -#+ [Python] Move the SwigPyObject, SwigPyPacked, SwigVarLink (renamed from -#+ swigvarlink) support Python types to the SWIG runtime module (currently called -#+ swig_runtime_data5). -#+ -#+ Note that these affect the Python runtime implementation, so the recently bumped -#+ SWIG_RUNTIME_VERSION to 5 for all scripting languages will now include this change. -#+ -# 2025-05-10: jschueller, wsfulton -# [Python] #2881 #3061 #3160 DeprecationWarning fixes when using 'python -Walways' -# or if using one of the types being warned about: -diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg -index 2ef79f348..e7164725d 100644 ---- a/Lib/python/pyrun.swg -+++ b/Lib/python/pyrun.swg -@@ -257,7 +257,7 @@ typedef struct swig_varlinkobject { - } swig_varlinkobject; - - SWIGINTERN PyObject * --swig_varlink_repr(PyObject *SWIGUNUSEDPARM(v)) { -+SwigVarLink_repr(PyObject *SWIGUNUSEDPARM(v)) { - #if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); - #else -@@ -266,7 +266,7 @@ swig_varlink_repr(PyObject *SWIGUNUSEDPARM(v)) { - } - - SWIGINTERN PyObject * --swig_varlink_str(PyObject *o) { -+SwigVarLink_str(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - #if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); -@@ -305,7 +305,7 @@ swig_varlink_str(PyObject *o) { - } - - SWIGINTERN void --swig_varlink_dealloc(PyObject *o) { -+SwigVarLink_dealloc(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - swig_globalvar *var = v->vars; - while (var) { -@@ -317,7 +317,7 @@ swig_varlink_dealloc(PyObject *o) { - } - - SWIGINTERN PyObject * --swig_varlink_getattr(PyObject *o, char *n) { -+SwigVarLink_getattr(PyObject *o, char *n) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - PyObject *res = NULL; - swig_globalvar *var = v->vars; -@@ -335,7 +335,7 @@ swig_varlink_getattr(PyObject *o, char *n) { - } - - SWIGINTERN int --swig_varlink_setattr(PyObject *o, char *n, PyObject *p) { -+SwigVarLink_setattr(PyObject *o, char *n, PyObject *p) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - int res = 1; - swig_globalvar *var = v->vars; -@@ -358,7 +358,7 @@ swig_varlink_setattr(PyObject *o, char *n, PyObject *p) { - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { -- static char varlink__doc__[] = "Swig variable link object"; -+ static char SwigVarLink_doc[] = "Swig variable link object"; - #ifndef SWIG_HEAPTYPES - static PyTypeObject varlink_type; - static int type_init = 0; -@@ -370,30 +370,30 @@ swig_varlink_type(void) { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - #endif -- SWIG_RUNTIME_MODULE ".swigvarlink", /* tp_name */ -+ SWIG_RUNTIME_MODULE ".SwigVarLink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ -- (destructor) swig_varlink_dealloc, /* tp_dealloc */ -+ (destructor) SwigVarLink_dealloc, /* tp_dealloc */ - #if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ - #else - (Py_ssize_t)0, /* tp_vectorcall_offset */ - #endif -- (getattrfunc) swig_varlink_getattr, /* tp_getattr */ -- (setattrfunc) swig_varlink_setattr, /* tp_setattr */ -+ (getattrfunc) SwigVarLink_getattr, /* tp_getattr */ -+ (setattrfunc) SwigVarLink_setattr, /* tp_setattr */ - 0, /* tp_compare */ -- (reprfunc) swig_varlink_repr, /* tp_repr */ -+ (reprfunc) SwigVarLink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ -- (reprfunc) swig_varlink_str, /* tp_str */ -+ (reprfunc) SwigVarLink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ -- varlink__doc__, /* tp_doc */ -+ SwigVarLink_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ -@@ -429,22 +429,22 @@ swig_varlink_type(void) { - type_init = 1; - if (PyType_Ready(&varlink_type) < 0) - return NULL; -- if (PyModule_AddObject(runtime_data_module, "swigvarlink", (PyObject *)&varlink_type) == 0) -+ if (PyModule_AddObject(runtime_data_module, "SwigVarLink", (PyObject *)&varlink_type) == 0) - SWIG_Py_INCREF((PyObject *)&varlink_type); - } - return &varlink_type; - #else - PyType_Slot slots[] = { -- { Py_tp_dealloc, (void *)swig_varlink_dealloc }, -- { Py_tp_repr, (void *)swig_varlink_repr }, -- { Py_tp_getattr, (void *)swig_varlink_getattr }, -- { Py_tp_setattr, (void *)swig_varlink_setattr }, -- { Py_tp_str, (void *)swig_varlink_str }, -- { Py_tp_doc, (void *)varlink__doc__ }, -+ { Py_tp_dealloc, (void *)SwigVarLink_dealloc }, -+ { Py_tp_repr, (void *)SwigVarLink_repr }, -+ { Py_tp_getattr, (void *)SwigVarLink_getattr }, -+ { Py_tp_setattr, (void *)SwigVarLink_setattr }, -+ { Py_tp_str, (void *)SwigVarLink_str }, -+ { Py_tp_doc, (void *)SwigVarLink_doc }, - { 0, NULL } - }; - PyType_Spec spec = { -- SWIG_RUNTIME_MODULE ".swigvarlink", -+ SWIG_RUNTIME_MODULE ".SwigVarLink", - sizeof(swig_varlinkobject), - 0, - Py_TPFLAGS_DEFAULT, -@@ -452,7 +452,7 @@ swig_varlink_type(void) { - }; - PyObject *pytype = PyType_FromSpec(&spec); - PyObject *runtime_data_module = SWIG_runtime_data_module(); -- if (pytype && PyModule_AddObject(runtime_data_module, "swigvarlink", pytype) == 0) -+ if (pytype && PyModule_AddObject(runtime_data_module, "SwigVarLink", pytype) == 0) - SWIG_Py_INCREF(pytype); - return (PyTypeObject *)pytype; - #endif -@@ -715,7 +715,7 @@ SwigPyObject_repr(SwigPyObject *v) - } - - /* We need a version taking two PyObject* parameters so it's a valid -- * PyCFunction to use in swigobject_methods[]. */ -+ * PyCFunction to use in SwigPyObject_methods[]. */ - SWIGRUNTIME PyObject * - SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) - { -@@ -922,7 +922,7 @@ SwigPyObject_own(PyObject *v, PyObject *args) - } - - static PyMethodDef --swigobject_methods[] = { -+SwigPyObject_methods[] = { - {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, - {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, -@@ -934,7 +934,7 @@ swigobject_methods[] = { - - SWIGRUNTIME PyTypeObject* - SwigPyObject_TypeOnce(void) { -- static char swigobject_doc[] = "Swig object holding a C/C++ pointer"; -+ static char SwigPyObject_doc[] = "Swig object holding a C/C++ pointer"; - #ifndef SWIG_HEAPTYPES - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ -@@ -1017,14 +1017,14 @@ SwigPyObject_TypeOnce(void) { - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ -- swigobject_doc, /* tp_doc */ -+ SwigPyObject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ -- swigobject_methods, /* tp_methods */ -+ SwigPyObject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ -@@ -1081,9 +1081,9 @@ SwigPyObject_TypeOnce(void) { - { Py_tp_dealloc, (void *)SwigPyObject_dealloc }, - { Py_tp_repr, (void *)SwigPyObject_repr }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, -- { Py_tp_doc, (void *)swigobject_doc }, -+ { Py_tp_doc, (void *)SwigPyObject_doc }, - { Py_tp_richcompare, (void *)SwigPyObject_richcompare }, -- { Py_tp_methods, (void *)swigobject_methods }, -+ { Py_tp_methods, (void *)SwigPyObject_methods }, - { Py_nb_int, (void *)SwigPyObject_long }, - { 0, NULL } - }; -@@ -1207,7 +1207,7 @@ SwigPyPacked_dealloc(PyObject *v) - - SWIGRUNTIME PyTypeObject* - SwigPyPacked_TypeOnce(void) { -- static char swigpacked_doc[] = "Swig object holding a C/C++ function pointer"; -+ static char SwigPyPacked_doc[] = "Swig object holding a C/C++ function pointer"; - #ifndef SWIG_HEAPTYPES - static PyTypeObject swigpypacked_type; - static int type_init = 0; -@@ -1246,7 +1246,7 @@ SwigPyPacked_TypeOnce(void) { - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ -- swigpacked_doc, /* tp_doc */ -+ SwigPyPacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ -@@ -1311,7 +1311,7 @@ SwigPyPacked_TypeOnce(void) { - { Py_tp_repr, (void *)SwigPyPacked_repr }, - { Py_tp_str, (void *)SwigPyPacked_str }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, -- { Py_tp_doc, (void *)swigpacked_doc }, -+ { Py_tp_doc, (void *)SwigPyPacked_doc }, - { 0, NULL } - }; - PyType_Spec spec = { --- -2.50.1 - - -From 831fc6069115b8a31bed5d0bcae221825cd43c18 Mon Sep 17 00:00:00 2001 -From: William S Fulton -Date: Tue, 13 May 2025 08:40:45 +0100 -Subject: [PATCH 4/5] Add docs on the python runtime module - ---- - Doc/Manual/Python.html | 50 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 50 insertions(+) - -diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html -index 7427ca4cf..cc82e9762 100644 ---- a/Doc/Manual/Python.html -+++ b/Doc/Manual/Python.html -@@ -1000,6 +1000,10 @@ module name, make sure you don't use the same name as a built-in - Python command or standard module name. -

- -+

-+There is also a further 'behind the scenes' Python runtime module, but this implementation detail is covered later. -+

-+ -

33.3.2 Functions

- - -@@ -2704,6 +2708,52 @@ in the file python/pyopers.swg in the SWIG library. -

- - -+

33.4.3 Python runtime module

-+ -+

-+In addition to the two Python modules that are generated by SWIG, there is also a third 'behind the scenes' Python runtime module. -+The runtime module is very much an implementation level detail, but is mentioned here for completeness and for the inquisitive! -+

-+ -+

-+SWIG implements a run-time type checker for checking a Python type/class as it passes between the Python and C/C++ layers. -+It is also used when multiple SWIG modules need to share type information with each other (when using the %import directive). -+More details can be found in the SWIG runtime code and run-time type checker sections. -+The runtime module contains the following: -+

-+ -+
    -+
  1. A Python Capsule containing a pointer to the underlying C module data structure used by the runtime type checker. For multiple modules to access the common runtime implementation. The Capsule is named type_pointer_capsule except when using -builtin when it is instead called type_pointer_capsule_builtin.
  2. -+
  3. The builtin type SwigPyObject - Swig object holding a C/C++ pointer. For 'normal' pointers, that is, not for function pointers nor member function pointers.
  4. -+
  5. The builtin type SwigPyPacked - Swig object holding a C/C++ function pointer. For C pointers to a function or C++ member function pointers.
  6. -+
  7. The builtin type SwigVarLink - Swig variable link object. The type used by the 'cvar' field for accessing C/C++ global variables.
  8. -+
-+ -+

-+If multiple SWIG modules are being used, the C/C++ wrapped proxy classes/types can be shared or used across the different modules via the SWIG runtime. -+The runtime is accessed and shared via the Capsule in the runtime module. -+The Python runtime module is implemented as a Python builtin module. While users are unlikely to use or import the runtime module directly, it can be inspected simply enough. -+The name of the module is swig_runtime_data appended with the runtime version as defined by SWIG_RUNTIME_VERSION. -+First import your SWIG generated module. Next find the exact runtime module name so you know what to import before inspecting it with say dir. -+The interpreter session below demonstrates this with a SWIG generated module called example: -+

-+ -+
-+
-+>>> import example
-+>>> import sys
-+>>> list(m for m in sys.modules if m.startswith("swig_runtime_data"))
-+['swig_runtime_data5']
-+>>> import swig_runtime_data5
-+>>> dir(swig_runtime_data5)
-+['SwigPyObject', 'SwigPyPacked', 'SwigVarLink', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'type_pointer_capsule']
-+
-+
-+ -+

-+Compatibility Note: Only the Capsule was stored in the Python runtime module prior to SWIG-4.4.0. -+

-+ -

33.4.3 Memory management

- - --- -2.50.1 - - -From d966fd3ba18370b5bf34b67ff376d88fb6d3e65b Mon Sep 17 00:00:00 2001 -From: William S Fulton -Date: Tue, 13 May 2025 21:42:56 +0100 -Subject: [PATCH 5/5] Test swig runtime module contains expected names - ---- - .../python/python_moduleimport_runme.py | 17 +++++++++++++++++ - Examples/test-suite/python_moduleimport.i | 2 ++ - 2 files changed, 19 insertions(+) - -diff --git a/Examples/test-suite/python/python_moduleimport_runme.py b/Examples/test-suite/python/python_moduleimport_runme.py -index cdb860730..8e0aa6121 100644 ---- a/Examples/test-suite/python/python_moduleimport_runme.py -+++ b/Examples/test-suite/python/python_moduleimport_runme.py -@@ -1,7 +1,24 @@ - import python_moduleimport - -+# Test custom moduleimport in %module - if python_moduleimport.simple_function(99) != 99: - raise RuntimeError("simple_function") - - if python_moduleimport.extra_import_variable != "custom import of _python_moduleimport": - raise RuntimeError("custom import") -+ -+ -+# Test the swig runtime module contains the expected names/types -+import importlib -+swig_runtime_version = python_moduleimport.runtime_version() -+swig_runtime_data = importlib.import_module("swig_runtime_data" + swig_runtime_version) # Equivalent to (for version 5): import swig_runtime_data5 as swig_runtime_data -+ -+names = dir(swig_runtime_data) -+expected_names = ("SwigPyObject", "SwigPyPacked", "SwigVarLink") -+for name in expected_names: -+ if name not in names: -+ raise RuntimeError("{} not in {}".format(name, names)) -+ -+cvar_type = type(python_moduleimport.cvar) -+if cvar_type.__name__ != "SwigVarLink": -+ raise RuntimeError("cvar type name is incorrect: {}".format(cvar_type.__name__)) -diff --git a/Examples/test-suite/python_moduleimport.i b/Examples/test-suite/python_moduleimport.i -index f62547dcd..f0d203433 100644 ---- a/Examples/test-suite/python_moduleimport.i -+++ b/Examples/test-suite/python_moduleimport.i -@@ -23,4 +23,6 @@ from $module import * - - %inline %{ - int simple_function(int i) { return i; } -+int globalvar = 99; -+const char * runtime_version() { return SWIG_RUNTIME_VERSION; } - %} --- -2.50.1 - diff --git a/swig.spec b/swig.spec index 54f3086..0b7b0f9 100644 --- a/swig.spec +++ b/swig.spec @@ -68,7 +68,7 @@ Summary: Connects C/C++/Objective C to some high-level programming languages Name: swig -Version: 4.4.0 +Version: 4.4.1 Release: 1%{?dist} License: GPL-3.0-or-later AND BSD-3-Clause URL: https://www.swig.org/ @@ -363,6 +363,9 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb %{_datadir}/%{name}/gdb %changelog +* Mon Dec 08 2025 Jitka Plesnikova - 4.4.1-1 +- 4.4.1 bump (rhbz#2419819, rhbz#2415440) + * Tue Oct 21 2025 Jitka Plesnikova - 4.4.0-1 - 4.4.0 bump (rhbz#2405182)