Skip to content

Commit

Permalink
Tidy up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Dec 14, 2023
1 parent 5c77494 commit a593360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/c/jpy_jtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ PyObject* JType_CreateJavaByteBufferWrapper(JNIEnv* jenv, PyObject* pyObj)
}

if (PyObject_GetBuffer(pyObj, pyBuffer, PyBUF_SIMPLE | PyBUF_C_CONTIGUOUS) != 0) {
PyErr_SetString(PyExc_ValueError, "byte_buffer: the Python object failed to return a contiguous buffer.");
PyErr_SetString(PyExc_ValueError, "JType_CreateJavaByteBufferWrapper: the Python object failed to return a contiguous buffer.");
PyMem_Free(pyBuffer);
return NULL;
}
Expand Down Expand Up @@ -1726,11 +1726,13 @@ int JType_ConvertPyArgToJByteBufferArg(JNIEnv* jenv, JPy_ParamDescriptor* paramD
JPy_JObj* obj = (JPy_JObj*) disposer->data;
value->l = obj->objectRef;
} else if (JObj_Check(pyArg)) {
JPy_JObj* obj = (JPy_JObj*) pyArg;
value->l = obj->objectRef;
disposer->data = NULL;
// If it is a wrapped Java object, it is always a global reference, so don't dispose it
disposer->DisposeArg = NULL;
JPy_JObj* obj = (JPy_JObj*) pyArg;
value->l = obj->objectRef;
} else {
PyErr_SetString(PyExc_RuntimeError, "jpy: internal error: Python argument incorrectly matched to Java ByteBuffer parameter.");
return -1;
}
return 0;
Expand Down Expand Up @@ -2454,7 +2456,6 @@ void JType_DisposeLocalObjectRefArg(JNIEnv* jenv, jvalue* value, void* data)

void JType_DisposeByteBufferArg(JNIEnv* jenv, jvalue* value, void* data)
{

PyObject* byteBufferWrapper = (PyObject*) data;
jobject jByteBuffer = (jobject) value->l;

Expand Down
2 changes: 1 addition & 1 deletion src/main/c/jpy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ PyObject* JPy_byte_buffer_internal(JNIEnv* jenv, PyObject* self, PyObject* args)
}

if (PyObject_CheckBuffer(pyObj) == 0) {
PyErr_SetString(PyExc_ValueError, "byte_buffer: argument 1 must be a Python object that supports the buffer protocol");
PyErr_SetString(PyExc_ValueError, "byte_buffer: argument 1 must be a Python object that supports the buffer protocol.");
return NULL;
}

Expand Down

0 comments on commit a593360

Please sign in to comment.