mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Dropped PyArg_ParseTuple() calls in functions taking no arguments.
This commit is contained in:
parent
2dc28ee7d8
commit
ed6a4c8b1a
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Replaced PyObject_CallFunction() with *ObjArgs() where more efficient.
|
||||
|
||||
* Dropped PyArg_ParseTuple() calls in functions taking no arguments.
|
||||
|
||||
* psycopg/microprotocols.c: small optimizations.
|
||||
|
||||
2010-11-08 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
|
|
@ -52,7 +52,6 @@ asis_str(asisObject *self)
|
|||
static PyObject *
|
||||
asis_getquoted(asisObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return asis_str(self);
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,7 @@ static struct PyMemberDef asisObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef asisObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)asis_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)asis_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"__conform__", (PyCFunction)asis_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -111,7 +111,6 @@ binary_str(binaryObject *self)
|
|||
static PyObject *
|
||||
binary_getquoted(binaryObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return binary_str(self);
|
||||
}
|
||||
|
||||
|
@ -162,7 +161,7 @@ static struct PyMemberDef binaryObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef binaryObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)binary_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)binary_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted binary string"},
|
||||
{"prepare", (PyCFunction)binary_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> prepare for binary encoding using conn"},
|
||||
|
|
|
@ -106,7 +106,6 @@ pydatetime_str(pydatetimeObject *self)
|
|||
static PyObject *
|
||||
pydatetime_getquoted(pydatetimeObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return pydatetime_str(self);
|
||||
}
|
||||
|
||||
|
@ -139,7 +138,7 @@ static struct PyMemberDef pydatetimeObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef pydatetimeObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL date/time"},
|
||||
{"__conform__", (PyCFunction)pydatetime_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -87,16 +87,14 @@ list_quote(listObject *self)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
list_str(listObject *self, PyObject *args)
|
||||
list_str(listObject *self)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return list_quote(self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
list_getquoted(listObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return list_quote(self);
|
||||
}
|
||||
|
||||
|
@ -148,7 +146,7 @@ static struct PyMemberDef listObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef listObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)list_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)list_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL date/time"},
|
||||
{"prepare", (PyCFunction)list_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> set encoding to conn->encoding"},
|
||||
|
|
|
@ -106,7 +106,6 @@ mxdatetime_str(mxdatetimeObject *self)
|
|||
static PyObject *
|
||||
mxdatetime_getquoted(mxdatetimeObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return mxdatetime_str(self);
|
||||
}
|
||||
|
||||
|
@ -139,7 +138,7 @@ static struct PyMemberDef mxdatetimeObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef mxdatetimeObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL date/time"},
|
||||
{"__conform__", (PyCFunction)mxdatetime_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -62,7 +62,6 @@ pboolean_str(pbooleanObject *self)
|
|||
static PyObject *
|
||||
pboolean_getquoted(pbooleanObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return pboolean_str(self);
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,7 @@ static struct PyMemberDef pbooleanObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef pbooleanObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pboolean_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)pboolean_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"__conform__", (PyCFunction)pboolean_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -84,7 +84,6 @@ end:
|
|||
static PyObject *
|
||||
pdecimal_getquoted(pdecimalObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return pdecimal_str(self);
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,7 @@ static struct PyMemberDef pdecimalObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef pdecimalObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pdecimal_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)pdecimal_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"__conform__", (PyCFunction)pdecimal_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -54,7 +54,6 @@ pfloat_str(pfloatObject *self)
|
|||
static PyObject *
|
||||
pfloat_getquoted(pfloatObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return pfloat_str(self);
|
||||
}
|
||||
|
||||
|
@ -86,7 +85,7 @@ static struct PyMemberDef pfloatObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef pfloatObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pfloat_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)pfloat_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"__conform__", (PyCFunction)pfloat_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
|
|
|
@ -136,7 +136,6 @@ qstring_str(qstringObject *self)
|
|||
static PyObject *
|
||||
qstring_getquoted(qstringObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
return qstring_str(self);
|
||||
}
|
||||
|
||||
|
@ -196,7 +195,7 @@ static struct PyMemberDef qstringObject_members[] = {
|
|||
/* object method table */
|
||||
|
||||
static PyMethodDef qstringObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)qstring_getquoted, METH_VARARGS,
|
||||
{"getquoted", (PyCFunction)qstring_getquoted, METH_NOARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"prepare", (PyCFunction)qstring_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> set encoding to conn->encoding and store conn"},
|
||||
|
|
|
@ -118,8 +118,6 @@ psyco_conn_close(connectionObject *self, PyObject *args)
|
|||
{
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
Dprintf("psyco_conn_close: closing connection at %p", self);
|
||||
conn_close(self);
|
||||
Dprintf("psyco_conn_close: connection at %p closed", self);
|
||||
|
@ -140,8 +138,6 @@ psyco_conn_commit(connectionObject *self, PyObject *args)
|
|||
EXC_IF_CONN_ASYNC(self, commit);
|
||||
EXC_IF_TPC_BEGIN(self, commit);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
if (conn_commit(self) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -162,8 +158,6 @@ psyco_conn_rollback(connectionObject *self, PyObject *args)
|
|||
EXC_IF_CONN_ASYNC(self, rollback);
|
||||
EXC_IF_TPC_BEGIN(self, rollback);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
if (conn_rollback(self) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -244,10 +238,6 @@ psyco_conn_tpc_prepare(connectionObject *self, PyObject *args)
|
|||
EXC_IF_CONN_ASYNC(self, tpc_prepare);
|
||||
EXC_IF_TPC_PREPARED(self, tpc_prepare);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (NULL == self->tpc_xid) {
|
||||
PyErr_SetString(ProgrammingError,
|
||||
"prepare must be called inside a two-phase transaction");
|
||||
|
@ -396,8 +386,6 @@ psyco_conn_tpc_recover(connectionObject *self, PyObject *args)
|
|||
EXC_IF_TPC_PREPARED(self, tpc_recover);
|
||||
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) { return NULL; }
|
||||
|
||||
return conn_tpc_recover(self);
|
||||
}
|
||||
|
||||
|
@ -486,8 +474,6 @@ psyco_conn_get_transaction_status(connectionObject *self, PyObject *args)
|
|||
{
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
return PyInt_FromLong((long)PQtransactionStatus(self->pgconn));
|
||||
}
|
||||
|
||||
|
@ -726,30 +712,30 @@ static struct PyMethodDef connectionObject_methods[] = {
|
|||
{"cursor", (PyCFunction)psyco_conn_cursor,
|
||||
METH_VARARGS|METH_KEYWORDS, psyco_conn_cursor_doc},
|
||||
{"close", (PyCFunction)psyco_conn_close,
|
||||
METH_VARARGS, psyco_conn_close_doc},
|
||||
METH_NOARGS, psyco_conn_close_doc},
|
||||
{"commit", (PyCFunction)psyco_conn_commit,
|
||||
METH_VARARGS, psyco_conn_commit_doc},
|
||||
METH_NOARGS, psyco_conn_commit_doc},
|
||||
{"rollback", (PyCFunction)psyco_conn_rollback,
|
||||
METH_VARARGS, psyco_conn_rollback_doc},
|
||||
METH_NOARGS, psyco_conn_rollback_doc},
|
||||
{"xid", (PyCFunction)psyco_conn_xid,
|
||||
METH_VARARGS|METH_KEYWORDS, psyco_conn_xid_doc},
|
||||
{"tpc_begin", (PyCFunction)psyco_conn_tpc_begin,
|
||||
METH_VARARGS, psyco_conn_tpc_begin_doc},
|
||||
{"tpc_prepare", (PyCFunction)psyco_conn_tpc_prepare,
|
||||
METH_VARARGS, psyco_conn_tpc_prepare_doc},
|
||||
METH_NOARGS, psyco_conn_tpc_prepare_doc},
|
||||
{"tpc_commit", (PyCFunction)psyco_conn_tpc_commit,
|
||||
METH_VARARGS, psyco_conn_tpc_commit_doc},
|
||||
{"tpc_rollback", (PyCFunction)psyco_conn_tpc_rollback,
|
||||
METH_VARARGS, psyco_conn_tpc_rollback_doc},
|
||||
{"tpc_recover", (PyCFunction)psyco_conn_tpc_recover,
|
||||
METH_VARARGS, psyco_conn_tpc_recover_doc},
|
||||
METH_NOARGS, psyco_conn_tpc_recover_doc},
|
||||
#ifdef PSYCOPG_EXTENSIONS
|
||||
{"set_isolation_level", (PyCFunction)psyco_conn_set_isolation_level,
|
||||
METH_VARARGS, psyco_conn_set_isolation_level_doc},
|
||||
{"set_client_encoding", (PyCFunction)psyco_conn_set_client_encoding,
|
||||
METH_VARARGS, psyco_conn_set_client_encoding_doc},
|
||||
{"get_transaction_status", (PyCFunction)psyco_conn_get_transaction_status,
|
||||
METH_VARARGS, psyco_conn_get_transaction_status_doc},
|
||||
METH_NOARGS, psyco_conn_get_transaction_status_doc},
|
||||
{"get_parameter_status", (PyCFunction)psyco_conn_get_parameter_status,
|
||||
METH_VARARGS, psyco_conn_get_parameter_status_doc},
|
||||
{"get_backend_pid", (PyCFunction)psyco_conn_get_backend_pid,
|
||||
|
|
|
@ -55,8 +55,6 @@ extern PyObject *pyPsycopgTzFixedOffsetTimezone;
|
|||
static PyObject *
|
||||
psyco_curs_close(cursorObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
EXC_IF_ASYNC_IN_PROGRESS(self, close);
|
||||
|
||||
|
@ -737,8 +735,6 @@ psyco_curs_fetchone(cursorObject *self, PyObject *args)
|
|||
{
|
||||
PyObject *res;
|
||||
|
||||
if (args && !PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
EXC_IF_ASYNC_IN_PROGRESS(self, fetchone);
|
||||
if (_psyco_curs_prefetch(self) < 0) return NULL;
|
||||
|
@ -871,10 +867,6 @@ psyco_curs_fetchall(cursorObject *self, PyObject *args)
|
|||
int i, size;
|
||||
PyObject *list, *res;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
EXC_IF_ASYNC_IN_PROGRESS(self, fetchall);
|
||||
if (_psyco_curs_prefetch(self) < 0) return NULL;
|
||||
|
@ -994,8 +986,6 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
|
|||
static PyObject *
|
||||
psyco_curs_nextset(cursorObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
|
||||
PyErr_SetString(NotSupportedError, "not supported by PostgreSQL");
|
||||
|
@ -1510,21 +1500,21 @@ cursor_next(PyObject *self)
|
|||
static struct PyMethodDef cursorObject_methods[] = {
|
||||
/* DBAPI-2.0 core */
|
||||
{"close", (PyCFunction)psyco_curs_close,
|
||||
METH_VARARGS, psyco_curs_close_doc},
|
||||
METH_NOARGS, psyco_curs_close_doc},
|
||||
{"execute", (PyCFunction)psyco_curs_execute,
|
||||
METH_VARARGS|METH_KEYWORDS, psyco_curs_execute_doc},
|
||||
{"executemany", (PyCFunction)psyco_curs_executemany,
|
||||
METH_VARARGS|METH_KEYWORDS, psyco_curs_executemany_doc},
|
||||
{"fetchone", (PyCFunction)psyco_curs_fetchone,
|
||||
METH_VARARGS, psyco_curs_fetchone_doc},
|
||||
METH_NOARGS, psyco_curs_fetchone_doc},
|
||||
{"fetchmany", (PyCFunction)psyco_curs_fetchmany,
|
||||
METH_VARARGS|METH_KEYWORDS, psyco_curs_fetchmany_doc},
|
||||
{"fetchall", (PyCFunction)psyco_curs_fetchall,
|
||||
METH_VARARGS, psyco_curs_fetchall_doc},
|
||||
METH_NOARGS, psyco_curs_fetchall_doc},
|
||||
{"callproc", (PyCFunction)psyco_curs_callproc,
|
||||
METH_VARARGS, psyco_curs_callproc_doc},
|
||||
{"nextset", (PyCFunction)psyco_curs_nextset,
|
||||
METH_VARARGS, psyco_curs_nextset_doc},
|
||||
METH_NOARGS, psyco_curs_nextset_doc},
|
||||
{"setinputsizes", (PyCFunction)psyco_curs_setinputsizes,
|
||||
METH_VARARGS, psyco_curs_setinputsizes_doc},
|
||||
{"setoutputsize", (PyCFunction)psyco_curs_setoutputsize,
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
static PyObject *
|
||||
psyco_lobj_close(lobjectObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
/* file-like objects can be closed multiple times and remember that
|
||||
closing the current transaction is equivalent to close all the
|
||||
opened large objects */
|
||||
|
@ -165,8 +163,6 @@ psyco_lobj_tell(lobjectObject *self, PyObject *args)
|
|||
{
|
||||
int pos;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
EXC_IF_LOBJ_CLOSED(self);
|
||||
EXC_IF_LOBJ_LEVEL0(self);
|
||||
EXC_IF_LOBJ_UNMARKED(self);
|
||||
|
@ -185,8 +181,6 @@ psyco_lobj_tell(lobjectObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
psyco_lobj_unlink(lobjectObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
if (lobject_unlink(self) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -266,11 +260,11 @@ static struct PyMethodDef lobjectObject_methods[] = {
|
|||
{"seek", (PyCFunction)psyco_lobj_seek,
|
||||
METH_VARARGS, psyco_lobj_seek_doc},
|
||||
{"tell", (PyCFunction)psyco_lobj_tell,
|
||||
METH_VARARGS, psyco_lobj_tell_doc},
|
||||
METH_NOARGS, psyco_lobj_tell_doc},
|
||||
{"close", (PyCFunction)psyco_lobj_close,
|
||||
METH_VARARGS, psyco_lobj_close_doc},
|
||||
METH_NOARGS, psyco_lobj_close_doc},
|
||||
{"unlink",(PyCFunction)psyco_lobj_unlink,
|
||||
METH_VARARGS, psyco_lobj_unlink_doc},
|
||||
METH_NOARGS, psyco_lobj_unlink_doc},
|
||||
{"export",(PyCFunction)psyco_lobj_export,
|
||||
METH_VARARGS, psyco_lobj_export_doc},
|
||||
#if PG_VERSION_HEX >= 0x080300
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
static PyObject *
|
||||
psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
@ -62,8 +60,6 @@ psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
@ -76,8 +72,6 @@ psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
@ -91,11 +85,11 @@ psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
|
|||
|
||||
static struct PyMethodDef isqlquoteObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)psyco_isqlquote_getquoted,
|
||||
METH_VARARGS, psyco_isqlquote_getquoted_doc},
|
||||
METH_NOARGS, psyco_isqlquote_getquoted_doc},
|
||||
{"getbinary", (PyCFunction)psyco_isqlquote_getbinary,
|
||||
METH_VARARGS, psyco_isqlquote_getbinary_doc},
|
||||
METH_NOARGS, psyco_isqlquote_getbinary_doc},
|
||||
{"getbuffer", (PyCFunction)psyco_isqlquote_getbuffer,
|
||||
METH_VARARGS, psyco_isqlquote_getbuffer_doc},
|
||||
METH_NOARGS, psyco_isqlquote_getbuffer_doc},
|
||||
/* {"prepare", (PyCFunction)psyco_isqlquote_prepare,
|
||||
METH_VARARGS, psyco_isqlquote_prepare_doc}, */
|
||||
{NULL}
|
||||
|
|
Loading…
Reference in New Issue
Block a user