are necessitated by the -builtin option. Notes on individual tests follow. grouping_runme.py : 'cvar' syntax for class variables is obsolete. li_std_string_extra_runme.py : li_std_wstring_runme.py : Reverse binary operators (e.g., __radd__) are not supported. threads_exception_runme.py : director_exception_runme.py : exception_order_runme.py : Throwing wrapped objects as exceptions is not supported. default_constructor_runme.py : Redundant functional interface (e.g., 'module.new_Foo()' for 'module.Foo()') is not provided. python_nondynamic_runme.py : I believe that this test script doesn't actually test the %pythonnondynamic feature correctly, and I believe that the feature itself is implemented incorrectly. With the -builtin option, %pythonnondynamic *is* implemented correctly, and I have modified the test script to exercise it correctly. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12416 626c5289-ae23-0410-ae9c-e8d60b6d4f22
79 lines
1.5 KiB
Python
79 lines
1.5 KiB
Python
from director_exception import *
|
|
|
|
class MyException(Exception):
|
|
def __init__(self, a, b):
|
|
self.msg = a + b
|
|
|
|
class MyFoo(Foo):
|
|
def ping(self):
|
|
raise NotImplementedError, "MyFoo::ping() EXCEPTION"
|
|
|
|
class MyFoo2(Foo):
|
|
def ping(self):
|
|
return True
|
|
pass # error: should return a string
|
|
|
|
class MyFoo3(Foo):
|
|
def ping(self):
|
|
raise MyException("foo", "bar")
|
|
|
|
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
|
|
# MyFoo.pong().
|
|
ok = 0
|
|
a = MyFoo()
|
|
b = launder(a)
|
|
try:
|
|
b.pong()
|
|
except NotImplementedError, e:
|
|
if str(e) == "MyFoo::ping() EXCEPTION":
|
|
ok = 1
|
|
else:
|
|
print "Unexpected error message: %s" % str(e)
|
|
except:
|
|
pass
|
|
if not ok:
|
|
raise RuntimeError
|
|
|
|
|
|
# Check that the director returns the appropriate TypeError if the return type
|
|
# is wrong.
|
|
ok = 0
|
|
a = MyFoo2()
|
|
b = launder(a)
|
|
try:
|
|
b.pong()
|
|
except TypeError, e:
|
|
if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
|
|
ok = 1
|
|
else:
|
|
print "Unexpected error message: %s" % str(e)
|
|
if not ok:
|
|
raise RuntimeError
|
|
|
|
|
|
# Check that the director can return an exception which requires two arguments
|
|
# to the constructor, without mangling it.
|
|
ok = 0
|
|
a = MyFoo3()
|
|
b = launder(a)
|
|
try:
|
|
b.pong()
|
|
except MyException, e:
|
|
if e.msg == 'foobar':
|
|
ok = 1
|
|
else:
|
|
print "Unexpected error message: %s" % str(e)
|
|
if not ok:
|
|
raise RuntimeError
|
|
|
|
# Throwing builtin classes as exceptions not supported
|
|
#try:
|
|
# raise Exception2()
|
|
#except Exception2:
|
|
# pass
|
|
|
|
# Throwing builtin classes as exceptions not supported
|
|
#try:
|
|
# raise Exception1()
|
|
#except Exception1:
|
|
# pass
|