Bypass Python tests throwing base classes as exceptions for -builtin
Throwing builtin classes as exceptions is not supported
This commit is contained in:
parent
34eb4b15d3
commit
bbad7f96ab
9 changed files with 65 additions and 30 deletions
|
|
@ -152,4 +152,10 @@ Foo *launder(Foo *f) {
|
||||||
virtual Bar return_Bar() { return Bar(); }
|
virtual Bar return_Bar() { return Bar(); }
|
||||||
virtual ~ReturnAllTypes() {}
|
virtual ~ReturnAllTypes() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,13 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int A::sfoovar = 1;
|
int A::sfoovar = 1;
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%template(ET_i) ET<int>;
|
%template(ET_i) ET<int>;
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,11 @@ void test_domain_error() throw(std::domain_error)
|
||||||
%include <std_except.i>
|
%include <std_except.i>
|
||||||
void test_domain_error() throw(std::domain_error)
|
void test_domain_error() throw(std::domain_error)
|
||||||
{ throw std::domain_error("std::domain_error"); }
|
{ throw std::domain_error("std::domain_error"); }
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -89,14 +89,10 @@ include $(srcdir)/../common.mk
|
||||||
BUILTIN_BROKEN = \
|
BUILTIN_BROKEN = \
|
||||||
autodoc.cpptest \
|
autodoc.cpptest \
|
||||||
default_constructor.cpptest \
|
default_constructor.cpptest \
|
||||||
director_exception.cpptest \
|
|
||||||
exception_order.cpptest \
|
|
||||||
import_nomodule.cpptest \
|
import_nomodule.cpptest \
|
||||||
li_std_except_as_class.cpptest \
|
|
||||||
li_std_string_extra.cpptest \
|
li_std_string_extra.cpptest \
|
||||||
li_std_wstring.cpptest \
|
li_std_wstring.cpptest \
|
||||||
python_abstractbase.cpptest \
|
python_abstractbase.cpptest \
|
||||||
threads_exception.cpptest
|
|
||||||
|
|
||||||
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,14 +68,13 @@ if not ok:
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
# This is expected to fail with -builtin option
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
try:
|
if not is_python_builtin():
|
||||||
raise Exception2()
|
try:
|
||||||
except Exception2:
|
raise Exception2()
|
||||||
pass
|
except Exception2:
|
||||||
|
pass
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
try:
|
||||||
# Throwing builtin classes as exceptions not supported
|
raise Exception1()
|
||||||
try:
|
except Exception1:
|
||||||
raise Exception1()
|
pass
|
||||||
except Exception1:
|
|
||||||
pass
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ from exception_order import *
|
||||||
|
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
|
if is_python_builtin():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
from li_std_except_as_class import *
|
from li_std_except_as_class import *
|
||||||
|
|
||||||
# std::domain_error hierarchy
|
# This test is expected to fail with -builtin option.
|
||||||
try: test_domain_error()
|
# Throwing builtin classes as exceptions not supported
|
||||||
except domain_error: pass
|
if is_python_builtin():
|
||||||
try: test_domain_error()
|
try: test_domain_error()
|
||||||
except logic_error: pass
|
except RuntimeError: pass
|
||||||
try: test_domain_error()
|
try: test_domain_error()
|
||||||
except exception: pass
|
except RuntimeError: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except RuntimeError: pass
|
||||||
|
else:
|
||||||
|
# std::domain_error hierarchy
|
||||||
|
try: test_domain_error()
|
||||||
|
except domain_error: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except logic_error: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except exception: pass
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,16 @@ except RuntimeError,e:
|
||||||
|
|
||||||
# This is expected fail with -builtin option
|
# This is expected fail with -builtin option
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
try:
|
if not threads_exception.is_python_builtin():
|
||||||
t.hosed()
|
try:
|
||||||
except threads_exception.Exc,e:
|
t.hosed()
|
||||||
code = e.code
|
except threads_exception.Exc,e:
|
||||||
if code != 42:
|
code = e.code
|
||||||
raise RuntimeError, "bad... code: %d" % code
|
if code != 42:
|
||||||
msg = e.msg
|
raise RuntimeError, "bad... code: %d" % code
|
||||||
if msg != "Hosed":
|
msg = e.msg
|
||||||
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
|
if msg != "Hosed":
|
||||||
|
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
|
||||||
|
|
||||||
for i in range(1,4):
|
for i in range(1,4):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,10 @@ public:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue