python: fix a reference leak in the (>py) word
parent
4029bf7a17
commit
a3fe45e7ac
|
@ -59,17 +59,19 @@ SPECIALIZED-ARRAY: void*
|
|||
: py-list>vector ( py-list -- vector )
|
||||
dup py-list-size iota [ py-list-get-item ] with V{ } map-as ;
|
||||
|
||||
DEFER: >py
|
||||
|
||||
GENERIC: (>py) ( obj -- obj' )
|
||||
M: string (>py) utf8>py-unicode ;
|
||||
M: math:fixnum (>py) PyLong_FromLong ;
|
||||
M: math:float (>py) PyFloat_FromDouble ;
|
||||
M: array (>py) [ (>py) ] map array>py-tuple ;
|
||||
M: array (>py) [ >py ] map array>py-tuple ;
|
||||
M: hashtable (>py)
|
||||
<py-dict> swap dupd [
|
||||
swapd [ (>py) ] bi@ py-dict-set-item
|
||||
] with assoc-each ;
|
||||
M: vector (>py)
|
||||
[ (>py) ] map vector>py-list ;
|
||||
[ >py ] map vector>py-list ;
|
||||
|
||||
: >py ( obj -- py-obj )
|
||||
(>py) &Py_DecRef ;
|
||||
|
|
|
@ -83,6 +83,8 @@ PY-FROM: sys => getrefcount ( obj -- n ) ;
|
|||
[ always-destructors get [ alien>> = ] with count ] bi =
|
||||
] py-test
|
||||
|
||||
|
||||
|
||||
PY-METHODS: file =>
|
||||
close ( self -- )
|
||||
fileno ( self -- n )
|
||||
|
@ -173,6 +175,13 @@ PY-FROM: wsgiref.simple_server => make_server ( iface port callback -- httpd ) ;
|
|||
] times
|
||||
] unit-test
|
||||
|
||||
! Another leaky test
|
||||
{ } [
|
||||
1000000 [
|
||||
[ { 9 8 7 6 5 4 3 2 1 } >py ] with-destructors drop
|
||||
] times
|
||||
] unit-test
|
||||
|
||||
|
||||
! Working with types
|
||||
PY-METHODS: obj =>
|
||||
|
|
Loading…
Reference in New Issue