python: tests and plug a reference leak in the exception throwing code
parent
ab75bcb60f
commit
a530a10187
|
@ -17,8 +17,10 @@ IN: python
|
||||||
[ t ] [ Py_IsInitialized ] py-test
|
[ t ] [ Py_IsInitialized ] py-test
|
||||||
|
|
||||||
! py-importing
|
! py-importing
|
||||||
[ { "ImportError" "No module named kolobi" } ] [
|
[ { "ImportError" "No module named kolobi" f } ] [
|
||||||
[ "kolobi" py-import ] [ [ type>> ] [ message>> ] bi 2array ] recover
|
[ "kolobi" py-import ] [
|
||||||
|
[ type>> ] [ message>> ] [ traceback>> ] tri 3array
|
||||||
|
] recover
|
||||||
] py-test
|
] py-test
|
||||||
|
|
||||||
! setattr
|
! setattr
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: arrays assocs destructors fry io.files.temp kernel math
|
USING: accessors arrays assocs continuations destructors fry io.files.temp
|
||||||
namespaces python python.ffi python.objects sequences sets
|
kernel math namespaces python python.ffi python.objects python.syntax
|
||||||
splitting tools.test unicode.categories ;
|
sequences sets splitting tools.test unicode.categories ;
|
||||||
IN: python.syntax
|
IN: python.syntax.tests
|
||||||
|
|
||||||
: py-test ( result quot -- )
|
: py-test ( result quot -- )
|
||||||
'[ _ with-destructors ] unit-test ; inline
|
'[ _ with-destructors ] unit-test ; inline
|
||||||
|
@ -13,7 +13,7 @@ PY-FROM: os =>
|
||||||
|
|
||||||
[ t ] [ getpid py> integer? ] unit-test
|
[ t ] [ getpid py> integer? ] unit-test
|
||||||
|
|
||||||
! ! Automatic tuple unpacking
|
! Automatic tuple unpacking
|
||||||
PY-FROM: os.path =>
|
PY-FROM: os.path =>
|
||||||
basename ( x -- x' )
|
basename ( x -- x' )
|
||||||
splitext ( x -- base ext ) ;
|
splitext ( x -- base ext ) ;
|
||||||
|
@ -153,3 +153,16 @@ PY-METHODS: ArgumentParser =>
|
||||||
|
|
||||||
! Can you pass a callback written in factor to a python function?
|
! Can you pass a callback written in factor to a python function?
|
||||||
PY-FROM: wsgiref.simple_server => make_server ( iface port callback -- httpd ) ;
|
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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: arrays kernel python python.syntax sequences ;
|
USING: arrays kernel python python.ffi python.syntax sequences ;
|
||||||
IN: python.throwing
|
IN: python.throwing
|
||||||
|
|
||||||
ERROR: python-error type message traceback ;
|
ERROR: python-error type message traceback ;
|
||||||
|
@ -10,5 +10,9 @@ PY-METHODS: obj =>
|
||||||
__str__ ( o -- str ) ;
|
__str__ ( o -- str ) ;
|
||||||
|
|
||||||
: throw-error ( ptype pvalue ptraceback -- )
|
: 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 ;
|
||||||
|
|
Loading…
Reference in New Issue