Bypass Python tests throwing base classes as exceptions for -builtin

Throwing builtin classes as exceptions is not supported
This commit is contained in:
William S Fulton 2014-10-02 20:03:40 +01:00
commit bbad7f96ab
9 changed files with 65 additions and 30 deletions

View file

@ -152,4 +152,10 @@ Foo *launder(Foo *f) {
virtual Bar return_Bar() { return Bar(); }
virtual ~ReturnAllTypes() {}
};
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
%}

View file

@ -125,6 +125,13 @@
}
};
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>;

View file

@ -23,3 +23,11 @@ void test_domain_error() throw(std::domain_error)
%include <std_except.i>
void test_domain_error() throw(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
%}

View file

@ -89,14 +89,10 @@ include $(srcdir)/../common.mk
BUILTIN_BROKEN = \
autodoc.cpptest \
default_constructor.cpptest \
director_exception.cpptest \
exception_order.cpptest \
import_nomodule.cpptest \
li_std_except_as_class.cpptest \
li_std_string_extra.cpptest \
li_std_wstring.cpptest \
python_abstractbase.cpptest \
threads_exception.cpptest
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))

View file

@ -68,14 +68,13 @@ if not ok:
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
raise Exception2()
except Exception2:
pass
if not is_python_builtin():
try:
raise Exception2()
except Exception2:
pass
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
raise Exception1()
except Exception1:
pass
try:
raise Exception1()
except Exception1:
pass

View file

@ -2,6 +2,8 @@ from exception_order import *
# This test is expected to fail with -builtin option.
# Throwing builtin classes as exceptions not supported
if is_python_builtin():
exit(0)
a = A()

View file

@ -1,9 +1,19 @@
from li_std_except_as_class import *
# 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
# This test is expected to fail with -builtin option.
# Throwing builtin classes as exceptions not supported
if is_python_builtin():
try: test_domain_error()
except RuntimeError: pass
try: test_domain_error()
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

View file

@ -20,15 +20,16 @@ except RuntimeError,e:
# This is expected fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
t.hosed()
except threads_exception.Exc,e:
code = e.code
if code != 42:
raise RuntimeError, "bad... code: %d" % code
msg = e.msg
if msg != "Hosed":
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
if not threads_exception.is_python_builtin():
try:
t.hosed()
except threads_exception.Exc,e:
code = e.code
if code != 42:
raise RuntimeError, "bad... code: %d" % code
msg = e.msg
if msg != "Hosed":
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
for i in range(1,4):
try:

View file

@ -52,4 +52,10 @@ public:
return 1;
}
};
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
%}