Hi
I have changed the buffer_obj type from PyObject to PyByteArrayObject and now it works.
static PyObject *
Connection_writeRequestData (Connection *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = { "buffer", "length", NULL };
PyByteArrayObject *buffer_obj;
char *buffer; /* string from python */
char *data; /* data to send */
int length;
http_status_t status; /* Write status */
if (!PyArg_ParseTupleAndKeywords (args, kwds, "Oi", kwlist,
&buffer_obj, &length))
return NULL;
/*
* Assign result to buffer
*/
buffer = PyBytes_AsString ((PyObject*)buffer_obj);
/*
* Allocate memory and duplicate buffer
*/
data = (char *) malloc((size_t) length);
if (data == NULL)
return NULL;
memcpy (data, buffer, length);
debugprintf ("-> Connection_writeRequestData(length=%d)\n", length);
Connection_begin_allow_threads (self);
status = cupsWriteRequestData(self->http, data, length);
Connection_end_allow_threads (self);
if (status != HTTP_CONTINUE)
{
free (data);
set_ipp_error (cupsLastError (), cupsLastErrorString ());
debugprintf ("<- Connection_writeRequestData() = NULL\n");
return NULL;
}
free (data);
debugprintf ("<- Connection_writeRequestData() = %d\n", status);
#if PY_MAJOR_VERSION >= 3
return PyLong_FromLong (status);
#else
return PyInt_FromLong (status);
#endif
}
I hope this change is good for you, I have a poor experience with python c binding.
Thanks
Francesco
_______________________________________________
system-config-printer-devel mailing list
system-config-printer-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/system-config-printer-devel@lists.fedorahosted.org