1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include "pycurl.h"
static PyObject *
create_error_object(CurlObject *self, int code)
{
PyObject *s, *v;
if (strlen(self->error)) {
s = PyText_FromString_Ignore(self->error);
if (s == NULL) {
return NULL;
}
} else {
s = PyText_FromString_Ignore(curl_easy_strerror(code));
if (s == NULL) {
return NULL;
}
}
v = Py_BuildValue("(iO)", code, s);
if (v == NULL) {
Py_DECREF(s);
return NULL;
}
return v;
}
PYCURL_INTERNAL void
create_and_set_error_object(CurlObject *self, int code)
{
PyObject *e;
self->error[sizeof(self->error) - 1] = 0;
e = create_error_object(self, code);
if (e != NULL) {
PyErr_SetObject(ErrorObject, e);
Py_DECREF(e);
}
}
|