How to receive ArrayList of PyObjects via PyCallable

28 views
Skip to first unread message

Christoph Antes

unread,
Nov 12, 2020, 4:18:00 PM11/12/20
to Jep Project
Hello everyone,

i have the following problem: 
I would like to get a list of Python objects which are provided by a Python method. This method is called in Java via a PyCallable. However, it seems that I only get back an ArrayList of strings, but not of the type PyObject. Does anyone have an idea what I am doing wrong here? :)

Example Code:
ArrayList<PyObject> list = function.callAs(ArrayList.class);
System.out.println(list.getClass());
System.out.println(list.get(0).getClass());

Output:
class java.util.ArrayList
Exception in thread "main" java.lang.ClassCastException: class java.lang.String cannot be cast to class jep.python.PyObject

Best regards
Chris

Ben Steffensmeier

unread,
Nov 12, 2020, 5:41:11 PM11/12/20
to Jep Project
I suspect you are getting bitten by a known issue that causes python objects to be converted to strings. We have actually corrected that issue on the dev_4.0 branch in github so you may want to try out that branch and see if it solves your problem. If it does solve your problem then let us know.

Ben

Christoph Antes

unread,
Nov 14, 2020, 5:44:48 AM11/14/20
to Jep Project

Hi, Ben,
with dev_4.0 it now works fine. Thanks!

Chris
Reply all
Reply to author
Forward
0 new messages