diff --git a/extra/python/python-tests.factor b/extra/python/python-tests.factor index 582e6bfe0c..837e73475b 100644 --- a/extra/python/python-tests.factor +++ b/extra/python/python-tests.factor @@ -17,8 +17,10 @@ IN: python [ t ] [ Py_IsInitialized ] py-test ! py-importing -[ { "ImportError" "No module named kolobi" } ] [ - [ "kolobi" py-import ] [ [ type>> ] [ message>> ] bi 2array ] recover +[ { "ImportError" "No module named kolobi" f } ] [ + [ "kolobi" py-import ] [ + [ type>> ] [ message>> ] [ traceback>> ] tri 3array + ] recover ] py-test ! setattr diff --git a/extra/python/syntax/syntax-tests.factor b/extra/python/syntax/syntax-tests.factor index 23599661e0..c107dce225 100644 --- a/extra/python/syntax/syntax-tests.factor +++ b/extra/python/syntax/syntax-tests.factor @@ -1,7 +1,7 @@ -USING: arrays assocs destructors fry io.files.temp kernel math -namespaces python python.ffi python.objects sequences sets -splitting tools.test unicode.categories ; -IN: python.syntax +USING: accessors arrays assocs continuations destructors fry io.files.temp +kernel math namespaces python python.ffi python.objects python.syntax +sequences sets splitting tools.test unicode.categories ; +IN: python.syntax.tests : py-test ( result quot -- ) '[ _ with-destructors ] unit-test ; inline @@ -13,7 +13,7 @@ PY-FROM: os => [ t ] [ getpid py> integer? ] unit-test -! ! Automatic tuple unpacking +! Automatic tuple unpacking PY-FROM: os.path => basename ( x -- x' ) splitext ( x -- base ext ) ; @@ -153,3 +153,16 @@ PY-METHODS: ArgumentParser => ! Can you pass a callback written in factor to a python function? PY-FROM: wsgiref.simple_server => make_server ( iface port callback -- httpd ) ; + +{ t } [ + [ 987 >py basename ] [ traceback>> ] recover length 0 > +] unit-test + +! Test if exceptions leak references. If so, the test will leak a few +! hundred megs of memory. Enough to be noticed but not to slow down +! the tests too much. +{ } [ + 100000 [ + [ [ 987 >py basename drop ] ignore-errors ] with-destructors + ] times +] unit-test diff --git a/extra/python/throwing/throwing.factor b/extra/python/throwing/throwing.factor index f18aedfff7..e12bd263e3 100644 --- a/extra/python/throwing/throwing.factor +++ b/extra/python/throwing/throwing.factor @@ -1,4 +1,4 @@ -USING: arrays kernel python python.syntax sequences ; +USING: arrays kernel python python.ffi python.syntax sequences ; IN: python.throwing ERROR: python-error type message traceback ; @@ -10,5 +10,9 @@ PY-METHODS: obj => __str__ ( o -- str ) ; : throw-error ( ptype pvalue ptraceback -- ) - [ $__name__ py> ] [ __str__ py> ] [ [ format_tb py> ] [ f ] if* ] tri* - python-error ; + [ + [ $__name__ py> ] + [ __str__ py> ] + [ [ format_tb py> ] [ f ] if* ] tri* + ] 3keep + [ Py_DecRef ] tri@ python-error ;