Use the Py_RETURN_NONE macro

This commit is contained in:
Daniele Varrazzo 2013-04-05 01:25:05 +01:00
parent 67c8250081
commit beea32ef03
16 changed files with 49 additions and 79 deletions

View File

@ -159,8 +159,7 @@ binary_prepare(binaryObject *self, PyObject *args)
self->conn = conn;
Py_INCREF(self->conn);
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
static PyObject *

View File

@ -107,8 +107,7 @@ list_prepare(listObject *self, PyObject *args)
Py_INCREF(conn);
self->connection = conn;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
static PyObject *

View File

@ -128,8 +128,7 @@ qstring_prepare(qstringObject *self, PyObject *args)
Py_INCREF(conn);
self->conn = conn;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
static PyObject *

View File

@ -130,8 +130,7 @@ psyco_conn_close(connectionObject *self)
conn_close(self);
Dprintf("psyco_conn_close: connection at %p closed", self);
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -149,8 +148,7 @@ psyco_conn_commit(connectionObject *self)
if (conn_commit(self) < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -169,8 +167,7 @@ psyco_conn_rollback(connectionObject *self)
if (conn_rollback(self) < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -254,8 +251,7 @@ psyco_conn_tpc_prepare(connectionObject *self)
* can be performed until commit. */
self->status = CONN_STATUS_PREPARED;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -583,8 +579,7 @@ psyco_conn_set_session(connectionObject *self, PyObject *args, PyObject *kwargs)
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -666,8 +661,7 @@ psyco_conn_set_isolation_level(connectionObject *self, PyObject *args)
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* set_client_encoding method - set client encoding */
@ -730,8 +724,7 @@ psyco_conn_get_parameter_status(connectionObject *self, PyObject *args)
val = PQparameterStatus(self->pgconn, param);
if (!val) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
return conn_text_from_chars(self, val);
}
@ -831,8 +824,7 @@ psyco_conn_reset(connectionObject *self)
if (res < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
static PyObject *
@ -939,8 +931,7 @@ psyco_conn_cancel(connectionObject *self)
PyErr_SetString(OperationalError, errbuf);
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
#endif /* PSYCOPG_EXTENSIONS */

View File

@ -70,8 +70,7 @@ psyco_curs_close(cursorObject *self)
Dprintf("psyco_curs_close: cursor at %p closed", self);
exit:
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -496,8 +495,7 @@ psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
}
/* success */
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
#define psyco_curs_executemany_doc \
@ -553,8 +551,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
self->rowcount = rowcount;
if (!PyErr_Occurred()) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
else {
return NULL;
@ -778,8 +775,7 @@ psyco_curs_fetchone(cursorObject *self)
if (self->row >= self->rowcount) {
/* we exausted available data: return None */
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
res = _psyco_curs_buildrow(self, self->row);
@ -1103,8 +1099,7 @@ psyco_curs_setinputsizes(cursorObject *self, PyObject *args)
EXC_IF_CURS_CLOSED(self);
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -1124,8 +1119,7 @@ psyco_curs_setoutputsize(cursorObject *self, PyObject *args)
EXC_IF_CURS_CLOSED(self);
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -1189,8 +1183,7 @@ psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
if (_psyco_curs_prefetch(self) < 0) return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

View File

@ -58,8 +58,7 @@ psyco_diagnostics_get_field(diagnosticsObject *self, void *closure)
const char *errortext;
if (!self->err->pgres) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
errortext = PQresultErrorField(self->err->pgres, (Py_intptr_t) closure);

View File

@ -53,8 +53,7 @@ psyco_set_wait_callback(PyObject *self, PyObject *obj)
wait_callback = NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

View File

@ -59,8 +59,7 @@ psyco_lobj_close(lobjectObject *self, PyObject *args)
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* write method - write data to the lobject */
@ -215,8 +214,7 @@ psyco_lobj_unlink(lobjectObject *self, PyObject *args)
if (lobject_unlink(self) < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* export method - export lobject's content to given file */
@ -237,8 +235,7 @@ psyco_lobj_export(lobjectObject *self, PyObject *args)
if (lobject_export(self, filename) < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -272,8 +269,7 @@ psyco_lobj_truncate(lobjectObject *self, PyObject *args)
if (lobject_truncate(self, len) < 0)
return NULL;
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
#endif /* PG_VERSION_HEX >= 0x080300 */

View File

@ -42,8 +42,7 @@
static PyObject *
psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
{
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* getbinary - return quoted representation for object */
@ -54,8 +53,7 @@ psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
static PyObject *
psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
{
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* getbuffer - return quoted representation for object */
@ -66,8 +64,7 @@ psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
static PyObject *
psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
{
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

View File

@ -177,8 +177,7 @@ psyco_register_type(PyObject *self, PyObject *args)
if (0 > typecast_add(type, NULL, 0)) { return NULL; }
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

View File

@ -474,8 +474,7 @@ typecast_call(PyObject *obj, PyObject *args, PyObject *kwargs)
// If the string is not a string but a None value we're being called
// from a Python-defined caster.
if (!string) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
return typecast_cast(obj, string, length, cursor);

View File

@ -253,7 +253,7 @@ typecast_GENERIC_ARRAY_cast(const char *str, Py_ssize_t len, PyObject *curs)
Dprintf("typecast_GENERIC_ARRAY_cast: str = '%s',"
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
if (str[0] == '[')
typecast_array_cleanup(&str, &len);
if (str[0] != '{') {

View File

@ -31,7 +31,7 @@ typecast_INTEGER_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
char buffer[12];
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if (s[len] != '\0') {
strncpy(buffer, s, (size_t) len); buffer[len] = '\0';
s = buffer;
@ -49,7 +49,7 @@ typecast_LONGINTEGER_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
char buffer[24];
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if (s[len] != '\0') {
strncpy(buffer, s, (size_t) len); buffer[len] = '\0';
s = buffer;
@ -64,7 +64,7 @@ typecast_FLOAT_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
PyObject *str = NULL, *flo = NULL;
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if (!(str = Text_FromUTF8AndSize(s, len))) { return NULL; }
#if PY_MAJOR_VERSION < 3
flo = PyFloat_FromString(str, NULL);
@ -81,7 +81,7 @@ typecast_FLOAT_cast(const char *s, Py_ssize_t len, PyObject *curs)
static PyObject *
typecast_STRING_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
return PyString_FromStringAndSize(s, len);
}
#else
@ -95,7 +95,7 @@ typecast_UNICODE_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
char *enc;
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
enc = ((cursorObject*)curs)->conn->codec;
return PyUnicode_Decode(s, len, enc, NULL);
@ -108,7 +108,7 @@ typecast_BOOLEAN_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
PyObject *res;
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if (s[0] == 't')
res = Py_True;
@ -128,7 +128,7 @@ typecast_DECIMAL_cast(const char *s, Py_ssize_t len, PyObject *curs)
PyObject *decimalType;
char *buffer;
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if ((buffer = PyMem_Malloc(len+1)) == NULL)
return PyErr_NoMemory();

View File

@ -146,7 +146,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
char *buffer = NULL;
Py_ssize_t len;
if (s == NULL) {Py_INCREF(Py_None); return Py_None;}
if (s == NULL) { Py_RETURN_NONE; }
if (s[0] == '\\' && s[1] == 'x') {
/* This is a buffer escaped in hex format: libpq before 9.0 can't

View File

@ -48,7 +48,7 @@ typecast_PYDATE_cast(const char *str, Py_ssize_t len, PyObject *curs)
PyObject* obj = NULL;
int n, y=0, m=0, d=0;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
if (!strcmp(str, "infinity") || !strcmp(str, "-infinity")) {
if (str[0] == '-') {
@ -92,7 +92,7 @@ typecast_PYDATETIME_cast(const char *str, Py_ssize_t len, PyObject *curs)
int hh=0, mm=0, ss=0, us=0, tz=0;
const char *tp = NULL;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
/* check for infinity */
if (!strcmp(str, "infinity") || !strcmp(str, "-infinity")) {
@ -177,7 +177,7 @@ typecast_PYTIME_cast(const char *str, Py_ssize_t len, PyObject *curs)
PyObject *tzinfo_factory;
int n, hh=0, mm=0, ss=0, us=0, tz=0;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
n = typecast_parse_time(str, NULL, &len, &hh, &mm, &ss, &us, &tz);
Dprintf("typecast_PYTIME_cast: n = %d, len = " FORMAT_CODE_PY_SSIZE_T ", "
@ -226,7 +226,7 @@ typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs)
int part = 0, sec;
double micro;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
Dprintf("typecast_PYINTERVAL_cast: s = %s", str);

View File

@ -51,7 +51,7 @@ typecast_MXDATE_cast(const char *str, Py_ssize_t len, PyObject *curs)
int hh=0, mm=0, ss=0, us=0, tz=0;
const char *tp = NULL;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
Dprintf("typecast_MXDATE_cast: s = %s", str);
@ -99,7 +99,7 @@ typecast_MXTIME_cast(const char *str, Py_ssize_t len, PyObject *curs)
{
int n, hh=0, mm=0, ss=0, us=0, tz=0;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
Dprintf("typecast_MXTIME_cast: s = %s", str);
@ -129,7 +129,7 @@ typecast_MXINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs)
double v = 0.0, sign = 1.0;
int part = 0;
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
if (str == NULL) { Py_RETURN_NONE; }
Dprintf("typecast_MXINTERVAL_cast: s = %s", str);