Updated Patch3 with a more elaborated approach
This commit is contained in:
parent
0f6e2a04fd
commit
4c69e78e8d
@ -1,23 +1,109 @@
|
||||
From e06906bda0ea06f6b5fc15dfa8f55a2251a1bbef Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <bjoern.esser@gmail.com>
|
||||
Date: Fri, 3 Apr 2015 18:48:08 +0200
|
||||
Subject: [PATCH] Python: fix using `-builtin -modern -modernargs` results in
|
||||
segfaulting code (#256)
|
||||
From 416277b3a56646c2934ca9ee542a3f36d4f9a436 Mon Sep 17 00:00:00 2001
|
||||
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||
Date: Fri, 24 Apr 2015 21:08:17 +0100
|
||||
Subject: [PATCH] Python code generated with '-builtin -modernargs' segfaults
|
||||
for any method taking zero arguments.
|
||||
|
||||
Also fixes: "SystemError: error return without exception set" during error checking
|
||||
when using just -builtin and the incorrect number of arguments is passed to a class
|
||||
method expecting zero arguments.
|
||||
|
||||
Closes #256
|
||||
Closes #382
|
||||
---
|
||||
Source/Modules/python.cxx | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
CHANGES.current | 8 ++++
|
||||
.../test-suite/python/template_classes_runme.py | 44 ++++++++++++++++++++++
|
||||
Examples/test-suite/template_classes.i | 3 ++
|
||||
Source/Modules/python.cxx | 14 +++----
|
||||
4 files changed, 61 insertions(+), 8 deletions(-)
|
||||
create mode 100644 Examples/test-suite/python/template_classes_runme.py
|
||||
|
||||
diff --git a/Examples/test-suite/python/template_classes_runme.py b/Examples/test-suite/python/template_classes_runme.py
|
||||
new file mode 100644
|
||||
index 0000000..9c04fee
|
||||
--- /dev/null
|
||||
+++ b/Examples/test-suite/python/template_classes_runme.py
|
||||
@@ -0,0 +1,44 @@
|
||||
+from template_classes import *
|
||||
+
|
||||
+# This test is just testing incorrect number of arguments/parameters checking
|
||||
+
|
||||
+point = PointInt()
|
||||
+
|
||||
+rectangle = RectangleInt()
|
||||
+rectangle.setPoint(point)
|
||||
+rectangle.getPoint()
|
||||
+RectangleInt.static_noargs()
|
||||
+RectangleInt.static_onearg(1)
|
||||
+
|
||||
+fail = True
|
||||
+try:
|
||||
+ rectangle.setPoint()
|
||||
+except TypeError, e:
|
||||
+ fail = False
|
||||
+if fail:
|
||||
+ raise RuntimeError("argument count check failed")
|
||||
+
|
||||
+
|
||||
+fail = True
|
||||
+try:
|
||||
+ rectangle.getPoint(0)
|
||||
+except TypeError, e:
|
||||
+ fail = False
|
||||
+if fail:
|
||||
+ raise RuntimeError("argument count check failed")
|
||||
+
|
||||
+fail = True
|
||||
+try:
|
||||
+ RectangleInt.static_noargs(0)
|
||||
+except TypeError, e:
|
||||
+ fail = False
|
||||
+if fail:
|
||||
+ raise RuntimeError("argument count check failed")
|
||||
+
|
||||
+fail = True
|
||||
+try:
|
||||
+ RectangleInt.static_onearg()
|
||||
+except TypeError, e:
|
||||
+ fail = False
|
||||
+if fail:
|
||||
+ raise RuntimeError("argument count check failed")
|
||||
diff --git a/Examples/test-suite/template_classes.i b/Examples/test-suite/template_classes.i
|
||||
index ebe13bd..d357e41 100644
|
||||
--- a/Examples/test-suite/template_classes.i
|
||||
+++ b/Examples/test-suite/template_classes.i
|
||||
@@ -18,6 +18,9 @@ class RectangleTest {
|
||||
public:
|
||||
Point<T>& getPoint() {return point;}
|
||||
void setPoint(Point<T>& value) {point = value;}
|
||||
+
|
||||
+ static int static_noargs() { return 0; }
|
||||
+ static int static_onearg(int i) { return i; }
|
||||
private:
|
||||
Point<T> point;
|
||||
|
||||
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
|
||||
index 0e4a402..b2c429d 100644
|
||||
index c85e3b9..a6a81b5 100644
|
||||
--- a/Source/Modules/python.cxx
|
||||
+++ b/Source/Modules/python.cxx
|
||||
@@ -2718,7 +2718,7 @@ class PYTHON:public Language {
|
||||
Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,0)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments);
|
||||
}
|
||||
}
|
||||
@@ -2713,14 +2713,12 @@ class PYTHON:public Language {
|
||||
Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
|
||||
}
|
||||
|
||||
- if (use_parse || allow_kwargs || !modernargs) {
|
||||
- if (builtin && in_class && tuple_arguments == 0) {
|
||||
- Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_fail;\n");
|
||||
- } else {
|
||||
+ } else if (tuple_arguments > 0) {
|
||||
Printf(parse_args, "if(!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments);
|
||||
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
||||
}
|
||||
- Printf(parse_args, ":%s\"", iname);
|
||||
- Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
||||
- funpack = 0;
|
||||
- }
|
||||
+ if (builtin && in_class && tuple_arguments == 0) {
|
||||
+ Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname);
|
||||
+ } else if (use_parse || allow_kwargs || !modernargs) {
|
||||
+ Printf(parse_args, ":%s\"", iname);
|
||||
+ Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
||||
+ funpack = 0;
|
||||
} else {
|
||||
Clear(parse_args);
|
||||
if (funpack) {
|
||||
|
@ -39,7 +39,7 @@
|
||||
Summary: Connects C/C++/Objective C to some high-level programming languages
|
||||
Name: swig
|
||||
Version: 3.0.5
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
License: GPLv3+ and BSD
|
||||
URL: http://swig.sourceforge.net/
|
||||
Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
|
||||
@ -52,7 +52,7 @@ Patch1: swig207-setools.patch
|
||||
Patch2: swig-2.0.10-Fix-x390-build.patch
|
||||
# Fix segfaults of Python-wrappers when generating code with
|
||||
# `-buildin -modern -modernargs`. Patch is upstreamed, see patch-url.
|
||||
Patch3: https://github.com/swig/swig/pull/372.patch#/swig-3.0.5_fix-python-modern-buildin.patch
|
||||
Patch3: https://github.com/swig/swig/commit/416277b3a56646c2934ca9ee542a3f36d4f9a436.patch#/swig-3.0.5_fix-python-modern-buildin.patch
|
||||
|
||||
BuildRequires: perl, python2-devel, pcre-devel
|
||||
BuildRequires: autoconf, automake, gawk, dos2unix
|
||||
@ -206,6 +206,9 @@ ln -fs ../../bin/ccache-swig %{buildroot}%{_libdir}/ccache/swig
|
||||
%doc Doc Examples LICENSE LICENSE-GPL LICENSE-UNIVERSITIES COPYRIGHT
|
||||
|
||||
%changelog
|
||||
* Sat Apr 25 2015 Björn Esser <bjoern.esser@gmail.com> - 3.0.5-6
|
||||
- Updated Patch3 with a more elaborated approach
|
||||
|
||||
* Sat Apr 04 2015 Björn Esser <bjoern.esser@gmail.com> - 3.0.5-5
|
||||
- Disable Ruby-testsuite on fc23 when building on armv7. It currently
|
||||
segfaults for unknown reason.
|
||||
|
Loading…
Reference in New Issue
Block a user