Skip to content

ISSUE-224: Null Pointer Exception on python-as-map iterator without explicit casting #224

Closed
@jjtolton

Description

@jjtolton
(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: null

Note:
This works

(py.. (__main__/Thing) (__call__  (python/dict {})  )) ;;=> {}  

See conversation for more details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions