ninia / jep

Embed Python in Java
Other
1.3k stars 147 forks source link

Exception while trying to invoke a python function which returns a bytestring-jep.JepException: <class 'BufferError'>: Object is not writable. #373

Closed XhinoMullaymeri closed 2 years ago

XhinoMullaymeri commented 2 years ago

Problem I am trying to invoke a python function which returns a bytestring and I keep getting an exception. Same code did run without any issues using Jep 3.9.1.

Sample code/over simplified : Python

    def get_binary(arg_1, arg_2):
          return b'binary'

Java

import jep.Interpreter;
Interpreter interpreter;
byte[] myBinary;
myBinary = (byte[]) interpreter.invoke("get_binary", ["a1","a2"]);

Exception

    jep.JepException: <class 'BufferError'>: Object is not writable.
        at jep.Jep.invoke(Native Method)
        at jep.Jep.invoke(Jep.java:257)

Environment (please complete the following information):

bsteffensmeier commented 2 years ago

Thanks for reporting this issue and providing an easily repeatable test case, I agree it is a significant regression. I have posted a pull request that I believe fixes your issue. If you can, consider testing the change in the PR against your specific use case and verify it fixes your problem.

XhinoMullaymeri commented 2 years ago

Hello Ben, I can confirm that the change in the PR solved my case. Thanks for the fast response!