diff --git a/.gitignore b/.gitignore index 8cec1dc..3a819d9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,3 @@ swig-2.0.0.tar.gz /swig-4.1.1.tar.gz /swig-4.2.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 -/swig-4.4.1.tar.gz diff --git a/sources b/sources index f6fe3ce..e92004d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (swig-4.4.1.tar.gz) = 103ddb4a5914f28e6739a006d35042c701e55ba05066acff3f3609befb5f43f253ea717fc41d06c93d8fb187ded4399c12c94665b93dc06d0fb835069391c7c7 +SHA512 (swig-4.2.1.tar.gz) = 019dee5a46d57e1030eef47cd5d007ccaadbdcd4e53cd30d7c795f0118ecf4406a78185534502c81c5f6d7bac0713256e7e19b20b5a2d14e2c552219edbaf5cf diff --git a/swig-R-Fix-gcc-s-Wformat-security-warning-in-R-Raise-functi.patch b/swig-R-Fix-gcc-s-Wformat-security-warning-in-R-Raise-functi.patch new file mode 100644 index 0000000..0c0cd61 --- /dev/null +++ b/swig-R-Fix-gcc-s-Wformat-security-warning-in-R-Raise-functi.patch @@ -0,0 +1,27 @@ +From 3d5157514889c668bc14c245246c388eb23615ea Mon Sep 17 00:00:00 2001 +From: pekkarr +Date: Mon, 29 Apr 2024 10:00:38 +0300 +Subject: [PATCH] Fix gcc's -Wformat-security warning in R Raise function + (#2896) + +The `Rf_error` function takes a format string as its first argument. +--- + Lib/r/r.swg | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/r/r.swg b/Lib/r/r.swg +index c1ce37c3e..63b69d8cf 100644 +--- a/Lib/r/r.swg ++++ b/Lib/r/r.swg +@@ -28,7 +28,7 @@ SWIGEXPORT void SWIG_init(void) { + + %runtime %{ + SWIGINTERN void SWIG_R_Raise(SEXP obj, const char *msg) { +- Rf_error(Rf_isString(obj) ? CHAR(Rf_asChar(obj)) : msg); ++ Rf_error("%s", Rf_isString(obj) ? CHAR(Rf_asChar(obj)) : msg); + } + %} + +-- +2.44.0 + diff --git a/swig-java-Avoid-using-deprecated-API-in-doxygen-example.patch b/swig-java-Avoid-using-deprecated-API-in-doxygen-example.patch new file mode 100644 index 0000000..44f449e --- /dev/null +++ b/swig-java-Avoid-using-deprecated-API-in-doxygen-example.patch @@ -0,0 +1,29 @@ +From 8a19cb77adfec168236e2c63d1a9d1a310f886cc Mon Sep 17 00:00:00 2001 +From: Olly Betts +Date: Fri, 1 Mar 2024 10:40:12 +1300 +Subject: [PATCH] [java] Avoid using deprecated API in doxygen example + +Passing a String command to Runtime.exec() has been deprecated since +Java 18. +--- + Examples/java/doxygen/runme.java | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Examples/java/doxygen/runme.java b/Examples/java/doxygen/runme.java +index 6b7bb3d01..5970521c8 100644 +--- a/Examples/java/doxygen/runme.java ++++ b/Examples/java/doxygen/runme.java +@@ -33,8 +33,8 @@ public class runme { + System.out.println(" perimeter = " + shapes[i].perimeter()); + } + +- String command = "javadoc -quiet -public -d javadocs example.java Shape.java Circle.java Square.java RectangleInt.java"; +- System.out.println("\nRunning: " + command); ++ String[] command = {"javadoc", "-quiet", "-public", "-d", "javadocs", "example.java", "Shape.java", "Circle.java", "Square.java", "RectangleInt.java"}; ++ System.out.println("\nRunning: " + String.join(" ", command)); + Process p = Runtime.getRuntime().exec(command); + int exitCode = p.waitFor(); + System.out.println("javadoc exited with code " + exitCode); +-- +2.44.0 + diff --git a/swig-java-Suppress-System.runFinalization-removal-warning.patch b/swig-java-Suppress-System.runFinalization-removal-warning.patch new file mode 100644 index 0000000..2ad135d --- /dev/null +++ b/swig-java-Suppress-System.runFinalization-removal-warning.patch @@ -0,0 +1,118 @@ +From ec56bff28d3ad5acf82e139a83da8135aa2dd618 Mon Sep 17 00:00:00 2001 +From: Olly Betts +Date: Fri, 1 Mar 2024 10:42:22 +1300 +Subject: [PATCH] [java] Suppress System.runFinalization() removal warnings + +These need to be addressed, but meanwhile it makes running the testsuite +with OpenJDK 21 or newer unhelpfully noisy so suppressing it seems more +helpful than not. + +Closes: #2819 +--- + Examples/test-suite/java/cpp11_std_unique_ptr_runme.java | 2 ++ + Examples/test-suite/java/director_pass_by_value_runme.java | 2 ++ + Examples/test-suite/java/java_director_runme.java | 2 ++ + Examples/test-suite/java/li_boost_intrusive_ptr_runme.java | 4 ++++ + Examples/test-suite/java/li_boost_shared_ptr_runme.java | 4 ++++ + Examples/test-suite/java/li_std_auto_ptr_runme.java | 2 ++ + 6 files changed, 16 insertions(+) + +diff --git a/Examples/test-suite/java/cpp11_std_unique_ptr_runme.java b/Examples/test-suite/java/cpp11_std_unique_ptr_runme.java +index f90ef7041..c5622f65f 100644 +--- a/Examples/test-suite/java/cpp11_std_unique_ptr_runme.java ++++ b/Examples/test-suite/java/cpp11_std_unique_ptr_runme.java +@@ -10,6 +10,8 @@ public class cpp11_std_unique_ptr_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() + { + System.gc(); +diff --git a/Examples/test-suite/java/director_pass_by_value_runme.java b/Examples/test-suite/java/director_pass_by_value_runme.java +index 1d34c3b55..48ccabf73 100644 +--- a/Examples/test-suite/java/director_pass_by_value_runme.java ++++ b/Examples/test-suite/java/director_pass_by_value_runme.java +@@ -12,6 +12,8 @@ public class director_pass_by_value_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() { + System.gc(); + System.runFinalization(); +diff --git a/Examples/test-suite/java/java_director_runme.java b/Examples/test-suite/java/java_director_runme.java +index 2167d2621..40829463b 100644 +--- a/Examples/test-suite/java/java_director_runme.java ++++ b/Examples/test-suite/java/java_director_runme.java +@@ -13,6 +13,8 @@ public class java_director_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() + { + System.gc(); +diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java +index 750ec5067..721a78d56 100644 +--- a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java ++++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java +@@ -13,6 +13,8 @@ public class li_boost_intrusive_ptr_runme { + // Debugging flag + public final static boolean debug = false; + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() + { + System.gc(); +@@ -23,6 +25,8 @@ public class li_boost_intrusive_ptr_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + public static void main(String argv[]) + { + if (debug) +diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java +index b513fade7..c1ec7f7bf 100644 +--- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java ++++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java +@@ -13,6 +13,8 @@ public class li_boost_shared_ptr_runme { + // Debugging flag + public final static boolean debug = false; + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() + { + System.gc(); +@@ -23,6 +25,8 @@ public class li_boost_shared_ptr_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + public static void main(String argv[]) + { + if (debug) +diff --git a/Examples/test-suite/java/li_std_auto_ptr_runme.java b/Examples/test-suite/java/li_std_auto_ptr_runme.java +index 24e353ddc..978a72504 100644 +--- a/Examples/test-suite/java/li_std_auto_ptr_runme.java ++++ b/Examples/test-suite/java/li_std_auto_ptr_runme.java +@@ -10,6 +10,8 @@ public class li_std_auto_ptr_runme { + } + } + ++ // Suppress warning about System.runFinalization() call. ++ @SuppressWarnings({"deprecation", "removal"}) + private static void WaitForGC() + { + System.gc(); +-- +2.44.0 + diff --git a/swig-python-Add-li_std_string-runtime-test.patch b/swig-python-Add-li_std_string-runtime-test.patch new file mode 100644 index 0000000..fbd7c86 --- /dev/null +++ b/swig-python-Add-li_std_string-runtime-test.patch @@ -0,0 +1,140 @@ +From 32afafda3366841a2c3610f4ad87774881eef3ae Mon Sep 17 00:00:00 2001 +From: William S Fulton +Date: Sun, 20 Oct 2024 12:43:43 +0100 +Subject: [PATCH] Add li_std_string runtime test + +--- + .../test-suite/python/li_std_string_runme.py | 121 ++++++++++++++++++ + 1 file changed, 121 insertions(+) + create mode 100644 Examples/test-suite/python/li_std_string_runme.py + +diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_runme.py +new file mode 100644 +index 000000000..70f428193 +--- /dev/null ++++ b/Examples/test-suite/python/li_std_string_runme.py +@@ -0,0 +1,121 @@ ++from li_std_string import * ++ ++def check(condition): ++ if not condition: ++ raise RuntimeError ++ ++# Checking expected use of %typemap(in) std::string {} ++test_value("Fee") ++ ++# Checking expected result of %typemap(out) std::string {} ++check(test_value("Fi") == "Fi") ++ ++# Verify type-checking for %typemap(in) std::string {} ++exceptionRaised = False ++try: ++ test_value(0) ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ ++# Checking expected use of %typemap(in) const std::string & {} ++test_const_reference("Fo") ++ ++# Checking expected result of %typemap(out) const std::string& {} ++check(test_const_reference("Fum") == "Fum") ++ ++# Verify type-checking for %typemap(in) const std::string & {} ++exceptionRaised = False ++try: ++ test_const_reference(0) ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ ++# ++# Input and output typemaps for pointers and non-const references to ++# std::string are *not* supported; the following tests confirm ++# that none of these cases are slipping through. ++# ++ ++exceptionRaised = False ++try: ++ test_pointer("foo") ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ ++result = test_pointer_out() ++check(not isinstance(result, str)) ++ ++exceptionRaised = False ++try: ++ test_const_pointer("bar") ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ ++result = test_const_pointer_out() ++check(not isinstance(result, str)) ++ ++exceptionRaised = False ++try: ++ test_reference("foo") ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ ++result = test_reference_out() ++check(not isinstance(result, str)) ++ ++ ++# Member Strings ++myStructure = Structure() ++if myStructure.MemberString2 != "member string 2": ++ raise RuntimeError ++s = "Hello" ++myStructure.MemberString2 = s ++if myStructure.MemberString2 != s: ++ raise RuntimeError ++if myStructure.ConstMemberString != "const member string": ++ raise RuntimeError ++ ++ ++if cvar.Structure_StaticMemberString2 != "static member string 2": ++ raise RuntimeError ++cvar.Structure_StaticMemberString2 = s ++if cvar.Structure_StaticMemberString2 != s: ++ raise RuntimeError ++if Structure.ConstStaticMemberString != "const static member string": ++ raise RuntimeError ++ ++ ++if test_reference_input("hello") != "hello": ++ raise RuntimeError ++s = test_reference_inout("hello") ++if s != "hellohello": ++ raise RuntimeError ++if test_reference_output() != "output": ++ raise RuntimeError ++ ++ ++if stdstring_empty() != "": ++ raise RuntimeError ++ ++if c_empty() != "": ++ raise RuntimeError ++ ++ ++if c_null() != None: ++ raise RuntimeError ++ ++ ++if get_null(c_null()) != None: ++ raise RuntimeError ++ ++ ++if get_null(c_empty()) != "non-null": ++ raise RuntimeError ++ ++if get_null(stdstring_empty()) != "non-null": ++ raise RuntimeError +-- +2.47.0 + diff --git a/swig-python-Fix-seg-fault-passing-invalid-unicode-values-to-std-.patch b/swig-python-Fix-seg-fault-passing-invalid-unicode-values-to-std-.patch new file mode 100644 index 0000000..b78c04e --- /dev/null +++ b/swig-python-Fix-seg-fault-passing-invalid-unicode-values-to-std-.patch @@ -0,0 +1,244 @@ +From d06382ec2a48b9e93a06c7cef1f09bc6fa344fca Mon Sep 17 00:00:00 2001 +From: William S Fulton +Date: Sun, 20 Oct 2024 13:39:11 +0100 +Subject: [PATCH] Fix seg fault passing invalid unicode values to std::string + +Problem reported as starting with python-3.13. +Due to error not being cleared before calling Python C APIs. + +The alternative could have been to ensure SWIG_AsCharPtrAndSize +never returns with a pending error (not that easy). + +Closes #3051 +--- +# CHANGES.current | 4 ++ + .../test-suite/python/li_std_string_runme.py | 66 ++++++++++++------- + Lib/python/pytypemaps.swg | 3 + + Lib/typemaps/std_strings.swg | 8 +-- + Lib/typemaps/swigtypemaps.swg | 6 ++ + 5 files changed, 56 insertions(+), 31 deletions(-) + +#diff --git a/CHANGES.current b/CHANGES.current +#index 96a299fa6..568f88086 100644 +#--- a/CHANGES.current +#+++ b/CHANGES.current +#@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ +# Version 4.3.0 (in progress) +# =========================== +# +#+2024-10-20: wsfulton +#+ #3051 Fix seg fault passing invalid unicode values when expecting a +#+ std::string type - fix for python-3.13. +#+ +# 2024-10-19: olly +# [ruby] Documentation comments now use `true` and `false` for bool +# parameter default values, instead of `True` and `False` (which are +diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_runme.py +index 70f428193..1a57529e1 100644 +--- a/Examples/test-suite/python/li_std_string_runme.py ++++ b/Examples/test-suite/python/li_std_string_runme.py +@@ -1,9 +1,25 @@ ++import sys + from li_std_string import * + + def check(condition): + if not condition: + raise RuntimeError + ++# Bad Unicode input check ++# This check is run first to check that %error_clear is called the first time SWIG_AsPtr_std_string() ++# is called setting the descriptor singleton (by calling SWIG_TypeQuery()). ++# Bug https://github.com/swig/swig/issues/3051. ++exceptionRaised = False ++try: ++ if sys.version_info[0:2] < (3, 0): ++ v = u"./\uDCFC.conf" ++ else: ++ v = "./\uDCFC.conf" ++ test_value(v) ++except TypeError: ++ exceptionRaised = True ++check(exceptionRaised) ++ + # Checking expected use of %typemap(in) std::string {} + test_value("Fee") + +@@ -13,9 +29,9 @@ check(test_value("Fi") == "Fi") + # Verify type-checking for %typemap(in) std::string {} + exceptionRaised = False + try: +- test_value(0) ++ test_value(0) + except TypeError: +- exceptionRaised = True ++ exceptionRaised = True + check(exceptionRaised) + + # Checking expected use of %typemap(in) const std::string & {} +@@ -27,9 +43,9 @@ check(test_const_reference("Fum") == "Fum") + # Verify type-checking for %typemap(in) const std::string & {} + exceptionRaised = False + try: +- test_const_reference(0) ++ test_const_reference(0) + except TypeError: +- exceptionRaised = True ++ exceptionRaised = True + check(exceptionRaised) + + # +@@ -40,9 +56,9 @@ check(exceptionRaised) + + exceptionRaised = False + try: +- test_pointer("foo") ++ test_pointer("foo") + except TypeError: +- exceptionRaised = True ++ exceptionRaised = True + check(exceptionRaised) + + result = test_pointer_out() +@@ -50,9 +66,9 @@ check(not isinstance(result, str)) + + exceptionRaised = False + try: +- test_const_pointer("bar") ++ test_const_pointer("bar") + except TypeError: +- exceptionRaised = True ++ exceptionRaised = True + check(exceptionRaised) + + result = test_const_pointer_out() +@@ -60,9 +76,9 @@ check(not isinstance(result, str)) + + exceptionRaised = False + try: +- test_reference("foo") ++ test_reference("foo") + except TypeError: +- exceptionRaised = True ++ exceptionRaised = True + check(exceptionRaised) + + result = test_reference_out() +@@ -72,50 +88,50 @@ check(not isinstance(result, str)) + # Member Strings + myStructure = Structure() + if myStructure.MemberString2 != "member string 2": +- raise RuntimeError ++ raise RuntimeError + s = "Hello" + myStructure.MemberString2 = s + if myStructure.MemberString2 != s: +- raise RuntimeError ++ raise RuntimeError + if myStructure.ConstMemberString != "const member string": +- raise RuntimeError ++ raise RuntimeError + + + if cvar.Structure_StaticMemberString2 != "static member string 2": +- raise RuntimeError ++ raise RuntimeError + cvar.Structure_StaticMemberString2 = s + if cvar.Structure_StaticMemberString2 != s: +- raise RuntimeError ++ raise RuntimeError + if Structure.ConstStaticMemberString != "const static member string": +- raise RuntimeError ++ raise RuntimeError + + + if test_reference_input("hello") != "hello": +- raise RuntimeError ++ raise RuntimeError + s = test_reference_inout("hello") + if s != "hellohello": +- raise RuntimeError ++ raise RuntimeError + if test_reference_output() != "output": +- raise RuntimeError ++ raise RuntimeError + + + if stdstring_empty() != "": +- raise RuntimeError ++ raise RuntimeError + + if c_empty() != "": +- raise RuntimeError ++ raise RuntimeError + + + if c_null() != None: +- raise RuntimeError ++ raise RuntimeError + + + if get_null(c_null()) != None: +- raise RuntimeError ++ raise RuntimeError + + + if get_null(c_empty()) != "non-null": +- raise RuntimeError ++ raise RuntimeError + + if get_null(stdstring_empty()) != "non-null": +- raise RuntimeError ++ raise RuntimeError +diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg +index 923c0e251..f4a6e4577 100644 +--- a/Lib/python/pytypemaps.swg ++++ b/Lib/python/pytypemaps.swg +@@ -57,6 +57,9 @@ + /* raise */ + #define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) + ++/* clear errors */ ++#define %error_clear PyErr_Clear() ++ + /* Include the unified typemap library */ + %include + +diff --git a/Lib/typemaps/std_strings.swg b/Lib/typemaps/std_strings.swg +index 842545826..28ef5e48d 100644 +--- a/Lib/typemaps/std_strings.swg ++++ b/Lib/typemaps/std_strings.swg +@@ -17,12 +17,8 @@ SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val) + return SWIG_OLDOBJ; + } + } else { +- static int init = 0; +- static swig_type_info* descriptor = 0; +- if (!init) { +- descriptor = SWIG_TypeQuery(#String " *"); +- init = 1; +- } ++ %error_clear; ++ static swig_type_info *descriptor = SWIG_TypeQuery(#String " *"); + if (descriptor) { + String *vptr; + int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0); +diff --git a/Lib/typemaps/swigtypemaps.swg b/Lib/typemaps/swigtypemaps.swg +index 3c3014f84..0c95c2f98 100644 +--- a/Lib/typemaps/swigtypemaps.swg ++++ b/Lib/typemaps/swigtypemaps.swg +@@ -121,6 +121,12 @@ + #endif + #endif + ++/*==== clear errors ====*/ ++ ++#ifndef %error_clear ++#define %error_clear ++#endif ++ + /*==== director output exception ====*/ + + #if defined(SWIG_DIRECTOR_TYPEMAPS) +-- +2.47.0 + diff --git a/swig-python-Python-3.13-deprecates-PyWeakref_GET_OBJECT.patch b/swig-python-Python-3.13-deprecates-PyWeakref_GET_OBJECT.patch new file mode 100644 index 0000000..268f55d --- /dev/null +++ b/swig-python-Python-3.13-deprecates-PyWeakref_GET_OBJECT.patch @@ -0,0 +1,27 @@ +From 7f0f267630386c41fbf44a0f6115d2555ba82451 Mon Sep 17 00:00:00 2001 +From: Julien Schueller +Date: Thu, 13 Jun 2024 15:32:46 +0200 +Subject: [PATCH] Python 3.13 deprecates PyWeakref_GET_OBJECT + +Closes #2863 +--- + Lib/python/pyrun.swg | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg +index 8381f16d27f..f7305eff108 100644 +--- a/Lib/python/pyrun.swg ++++ b/Lib/python/pyrun.swg +@@ -1343,7 +1343,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) + (void)obj; + # ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { ++#if PY_VERSION_HEX >= 0x030D0000 ++ PyWeakref_GetRef(pyobj, &pyobj); ++ Py_DECREF(pyobj); ++#else + pyobj = PyWeakref_GET_OBJECT(pyobj); ++#endif + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } diff --git a/swig-python-Python-3.13-strips-docstring-indent.patch b/swig-python-Python-3.13-strips-docstring-indent.patch new file mode 100644 index 0000000..d0fce06 --- /dev/null +++ b/swig-python-Python-3.13-strips-docstring-indent.patch @@ -0,0 +1,34 @@ +From ffa856c8dc1fa97e6896a2c5d5bd647c15df2284 Mon Sep 17 00:00:00 2001 +From: Julien Schueller +Date: Thu, 13 Jun 2024 15:31:26 +0200 +Subject: [PATCH] Python 3.13 strips docstring indent + +--- + Examples/test-suite/python/python_docstring_runme.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/Examples/test-suite/python/python_docstring_runme.py b/Examples/test-suite/python/python_docstring_runme.py +index a601ecb5430..101f9dd8a30 100644 +--- a/Examples/test-suite/python/python_docstring_runme.py ++++ b/Examples/test-suite/python/python_docstring_runme.py +@@ -1,5 +1,6 @@ + from python_docstring import * + import inspect ++import sys + + def check(got, expected): + expected_list = expected.split("\n") +@@ -87,9 +88,10 @@ def check(got, expected): + ) + + # One line doc special case, use __doc__ +-check(DocStrings.docstringX.__doc__, +- " one line docs" +- ) ++if sys.version_info[0:2] < (3, 13): ++ check(DocStrings.docstringX.__doc__, " one line docs") ++else: ++ check(DocStrings.docstringX.__doc__, "one line docs") + + check(inspect.getdoc(DocStrings.docstringX), + "one line docs" diff --git a/swig-python-Python-3.14-support.patch b/swig-python-Python-3.14-support.patch deleted file mode 100644 index ceee305..0000000 --- a/swig-python-Python-3.14-support.patch +++ /dev/null @@ -1,153 +0,0 @@ -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 0b7b0f9..81e3502 100644
--- a/swig.spec
+++ b/swig.spec
@@ -46,8 +46,7 @@
 %else
 %{!?guile:%global guile 1}
 %{!?octave:%global octave 1}
-# R-core requires tcl < 9.0.0
-%{!?Rlang:%global Rlang 0}
+%{!?Rlang:%global Rlang 1}
 %bcond_without build_ccache_swig
 %endif
 
@@ -56,7 +55,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 1}
+%{!?javalang:%global javalang 0}
 %endif
 
 # Do not run Go tests, they failed with 4.0.0 on ppc64le, s390
@@ -68,8 +67,8 @@
 
 Summary: Connects C/C++/Objective C to some high-level programming languages
 Name:    swig
-Version: 4.4.1
-Release: 1%{?dist}
+Version: 4.2.1
+Release: 9%{?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 +79,19 @@ Source2: description-ccache.h2m
 Source3: ccache-swig.sh
 Source4: ccache-swig.csh
 %endif
+# Small fixes for java tests, in upstream after 4.2.1
+Patch0:  swig-java-Avoid-using-deprecated-API-in-doxygen-example.patch
+Patch1:  swig-java-Suppress-System.runFinalization-removal-warning.patch
+# Fix gcc's -Wformat-security warning in R Raise function
+# https://github.com/swig/swig/pull/2896
+Patch2:  swig-R-Fix-gcc-s-Wformat-security-warning-in-R-Raise-functi.patch
+# Python 3.13 support: https://github.com/swig/swig/pull/2925
+Patch3:  swig-python-Python-3.13-strips-docstring-indent.patch
+Patch4:  swig-python-Python-3.13-deprecates-PyWeakref_GET_OBJECT.patch
+# Fix seg fault passing invalid unicode values to std::string
+# in upstream since 4.3.0
+Patch5:  swig-python-Add-li_std_string-runtime-test.patch
+Patch6:  swig-python-Fix-seg-fault-passing-invalid-unicode-values-to-std-.patch
 
 BuildRequires: coreutils
 BuildRequires: findutils
@@ -105,7 +117,7 @@ BuildRequires: boost-devel
 # Need when Source/CParse/parser.y is patched
 BuildRequires: bison
 %if %{tcl}
-BuildRequires: tcl-devel >= 9.0.0
+BuildRequires: tcl-devel
 %endif
 %if %{guile}
 BuildRequires: guile-devel
@@ -363,44 +375,8 @@ 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)
-
-* 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
-
-* 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
-
-* 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)
-
-* Mon Feb 17 2025 Jitka Plesnikova  - 4.3.0-5
-- Disable R tests, because they need tcl < 9
-
-* Sun Jan 19 2025 Fedora Release Engineering  - 4.3.0-4
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
-
-* Thu Nov 14 2024 Orion Poplawski  - 4.3.0-3
-- Rebuild for octave 9.2
-
-* Tue Oct 29 2024 Jitka Plesnikova  - 4.3.0-2
-- Fix precedence of casts
-
-* Mon Oct 21 2024 Jitka Plesnikova  - 4.3.0-1
-- 4.3.0 bump (rhbz#2320047)
+* Mon Dec 02 2024 Jitka Plesnikova  - 4.2.1-9
+- Fix seg fault passing invalid unicode values to std::string (rhbz#2318762)
 
 * Sat Jul 20 2024 Fedora Release Engineering  - 4.2.1-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild