clj-python / libpython-clj

Python bindings for Clojure
Eclipse Public License 2.0
1.06k stars 69 forks source link

Issue dereferencing JVM primitives / objects from codegen namespaces #163

Closed enragedginger closed 3 years ago

enragedginger commented 3 years ago

I'm using the cv2 library. I ran the codegen on it, and swapped out my require-python usage of the library with a standard Clojure :require. An error is thrown when deref-ing constants from the generated namespace. Codegen creates this: (def ^{:doc ""} COLOR_BGR2GRAY (as-jvm/generic-pyobject (py-global-delay (py/get-attr @src-obj* "COLOR_BGR2GRAY"))))

(py/get-attr @src-obj* "COLOR_BGR2GRAY") returns a java.lang.Long

When I try to use COLOR_BGR2GRAY, this error is thrown:

Error printing return value at tech.v3.datatype.ffi.ptr-value/unchecked-ptr-value (ptr_value.clj:17). Item 6 is not convertible to a C pointer

I can reproduce this error with this: (as-jvm/generic-pyobject (py-global-delay 6))

You can also replace 6 with some other JVM value (i.e. true or {:thing 1}) and reproduce the error