[ 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
-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
[ t ] [ getpid py> integer? ] unit-test
-! ! Automatic tuple unpacking
+! Automatic tuple unpacking
PY-FROM: os.path =>
basename ( x -- x' )
splitext ( x -- base ext ) ;
! 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
-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 ;
__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 ;