From d0b72f6192f075125502bfd726858faefc0c0471 Mon Sep 17 00:00:00 2001 From: James Tolton Date: Fri, 21 Oct 2022 13:41:57 -0400 Subject: [PATCH] Cast args of `py{*}` family of macros to python via `py/->python` --- src/libpython_clj2/python.clj | 2 +- test/libpython_clj2/python_test.clj | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libpython_clj2/python.clj b/src/libpython_clj2/python.clj index 5ebebf1..66e7940 100644 --- a/src/libpython_clj2/python.clj +++ b/src/libpython_clj2/python.clj @@ -663,7 +663,7 @@ nil :else ;; assumed to be method invocation - (list* (into (vector #'py. x instance-member) args)))) + (list* (into (vector #'py. x instance-member) (map (fn [arg] `(#'->python ~arg)) args))))) (handle-pydotdot x (list form)))) ([x form & more] (apply handle-pydotdot (handle-pydotdot x form) more))) diff --git a/test/libpython_clj2/python_test.clj b/test/libpython_clj2/python_test.clj index bc50c6d..e1cadad 100644 --- a/test/libpython_clj2/python_test.clj +++ b/test/libpython_clj2/python_test.clj @@ -422,6 +422,15 @@ class Foo: (is (= [5 2] (py/->jvm (py/get-attr pp "shape")))))) +(deftest null-pointer-on-python-iterator + (py/run-simple-string " +class Thing: + def __call__(this, data): + return {a: b for a, b in data.items()}") + (let [main (py/import-module "__main__") + thing (py/get-attr main "Thing")] + (py.. (thing) (__call__ {})))) + (comment (require '[libpython-clj.require :refer [require-python]])