ISSUE-224: Null Pointer Exception on python-as-map iterator without explicit casting
jjtolton opened this issue · comments
(require '[libpython-clj2.python :as py :refer [py.. py**] :reload true])
(py/initialize! :python-executable "venv/bin/python")
(require '[libpython-clj2.require :refer [require-python import-python]])
(import-python)
(py/run-simple-string "
class Thing:
def __call__(this, data):
return {a: b for a, b in data.items()}
" )
(py.. (__main__/Thing) (__call__ {} ))Expected: {}
Actual:
Traceback (most recent call last): File "<string>", line 4, in
__call__ File "<string>", line 4, in <dictcomp> File
"/home/jay/.pyenv/versions/3.7.13/lib/python3.7/_collections_abc.py",
line 743, in __iter__ for key in self._mapping: Exception:
java.lang.NullPointerException:java.lang.NullPointerException: nullNote:
This works
(py.. (__main__/Thing) (__call__ (python/dict {}) )) ;;=> {} See conversation for more details
The simplest test case for the problem is this:
(py/py. (libpython-clj2.python.bridge-as-python/map-as-python {}) __iter__)
Not sure, if you consider this public API, but it fails with NPE
This is not fixed by PR #225
Thanks for the test case! #227