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
This commit is contained in:
parent
e4d02d20ad
commit
416277b3a5
4 changed files with 61 additions and 8 deletions
|
|
@ -5,6 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.6 (in progress)
|
Version 3.0.6 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2015-04-24: wsfulton
|
||||||
|
[Python] Fix #256. 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.
|
||||||
|
|
||||||
2015-04-23: wsfulton
|
2015-04-23: wsfulton
|
||||||
[Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
|
[Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
|
||||||
|
|
||||||
|
|
|
||||||
44
Examples/test-suite/python/template_classes_runme.py
Normal file
44
Examples/test-suite/python/template_classes_runme.py
Normal file
|
|
@ -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")
|
||||||
|
|
@ -18,6 +18,9 @@ class RectangleTest {
|
||||||
public:
|
public:
|
||||||
Point<T>& getPoint() {return point;}
|
Point<T>& getPoint() {return point;}
|
||||||
void setPoint(Point<T>& value) {point = value;}
|
void setPoint(Point<T>& value) {point = value;}
|
||||||
|
|
||||||
|
static int static_noargs() { return 0; }
|
||||||
|
static int static_onearg(int i) { return i; }
|
||||||
private:
|
private:
|
||||||
Point<T> point;
|
Point<T> point;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2713,14 +2713,12 @@ public:
|
||||||
Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
|
Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_parse || allow_kwargs || !modernargs) {
|
|
||||||
if (builtin && in_class && tuple_arguments == 0) {
|
if (builtin && in_class && tuple_arguments == 0) {
|
||||||
Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_fail;\n");
|
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 {
|
} else if (use_parse || allow_kwargs || !modernargs) {
|
||||||
Printf(parse_args, ":%s\"", iname);
|
Printf(parse_args, ":%s\"", iname);
|
||||||
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
||||||
funpack = 0;
|
funpack = 0;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Clear(parse_args);
|
Clear(parse_args);
|
||||||
if (funpack) {
|
if (funpack) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue