diff --git a/python.scm b/python.scm index 3eeb950..5590fea 100644 --- a/python.scm +++ b/python.scm @@ -1611,7 +1611,7 @@ ___return(dst); ")) (define (procedure->PyObject*/function proc) - (python-SchemeProcedure (object->SchemeObject proc))) + (PyCell_Get (python-SchemeProcedure (object->SchemeObject proc)))) (define (PyObject*/list->vector src) (or ((c-lambda (PyObject*/list) scheme-object " diff --git a/test/test.scm b/test/test.scm index 42eac11..79fe673 100644 --- a/test/test.scm +++ b/test/test.scm @@ -62,6 +62,16 @@ (test-equal 11 (table-ref t "a" #f)) (test-equal 22 (table-ref t "b" #f))) +;; Procedure conversions +(let ((p (python-eval "foreign(lambda x: x)"))) + \s=`p + (test-assert \s==`p)) + +;; *args and **kwargs +(let ((p (python-eval "lambda x, *args, **kwargs: args if x else kwargs"))) + (test-equal #(1 2 3) (p #t 1 2 3)) + (test-equal (list->table '(("k" . 0) ("t" . 1))) (p #f k: 0 t: 1))) + ;;;---------------------------------------------------------------------------- ;; test basic Scheme to Python conversions