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 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
%} %}

View file

@ -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>;

View file

@ -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
%}

View file

@ -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))

View file

@ -68,13 +68,12 @@ 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
if not is_python_builtin():
try: try:
raise Exception2() raise Exception2()
except Exception2: except Exception2:
pass pass
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
try: try:
raise Exception1() raise Exception1()
except Exception1: except Exception1:

View file

@ -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()

View file

@ -1,5 +1,15 @@
from li_std_except_as_class import * from li_std_except_as_class import *
# 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 # std::domain_error hierarchy
try: test_domain_error() try: test_domain_error()
except domain_error: pass except domain_error: pass

View file

@ -20,6 +20,7 @@ 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
if not threads_exception.is_python_builtin():
try: try:
t.hosed() t.hosed()
except threads_exception.Exc,e: except threads_exception.Exc,e:

View file

@ -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
%} %}