Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit e494159

Browse files
authored
Merge pull request #121 from sbarnoud/patch-2
Corrected (again) invalid reference count
2 parents 22f4610 + e6686a0 commit e494159

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/c/jni/org_jpy_PyLib.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -926,17 +926,21 @@ PyObject* PyLib_CallAndReturnObject(JNIEnv *jenv, PyObject* pyObject, jboolean i
926926
goto error;
927927
}
928928
pyArg = JPy_FromJObjectWithType(jenv, jArg, paramType);
929-
(*jenv)->DeleteLocalRef(jenv, jParamClass);
930-
} else {
931-
pyArg = JPy_FromJObject(jenv, jArg);
929+
932930
// We must keep unchanged the reference counter when calling a Python method
933931
// with a complex Python object as parameter.
934932
// Per example:
935-
// PyObject x = pymodule.call("create_dataFrame");
936-
// String[] columns = pymodule.call("list",x.columns.values).getObjectArrayValue(String.class);
933+
// PyObject dt_X = kycProcessor.getDataFrame(inputColumns.toArray(new String[0]));
934+
// for (DataFrameColumn column : values) {
935+
// kycProcessor.addColumn(dt_X, column.getName(), column.getValues());
936+
// }
937937
if (paramType->componentType == NULL && paramType == JPy_JPyObject) {
938938
Py_INCREF(pyArg);
939939
}
940+
941+
(*jenv)->DeleteLocalRef(jenv, jParamClass);
942+
} else {
943+
pyArg = JPy_FromJObject(jenv, jArg);
940944
}
941945

942946
(*jenv)->DeleteLocalRef(jenv, jArg);

0 commit comments

Comments
 (0)