]> gitweb.factorcode.org Git - factor.git/commitdiff
python: fix a reference leak in the (>py) word
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 23 Oct 2014 23:18:57 +0000 (01:18 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 24 Oct 2014 00:01:46 +0000 (17:01 -0700)
extra/python/python.factor
extra/python/syntax/syntax-tests.factor

index 016749ebb5d1478bed178c381bd97db1cbd86a28..18f43ad55dd7b9fe62139603715a6046715e28e8 100644 (file)
@@ -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 ;
index eeaa91484e01fbf5e0332aba318d443b5577d88c..3ec5fa7b6e0c23ac301be629987cf6da62a9a865 100644 (file)
@@ -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 =>