Merge branch 'naming'

This commit is contained in:
Daniele Varrazzo 2019-03-18 01:54:44 +00:00
commit 8b7506f80d
34 changed files with 302 additions and 305 deletions

View File

@ -60,7 +60,7 @@ asis_getquoted(asisObject *self, PyObject *args)
static PyObject * static PyObject *
asis_str(asisObject *self) asis_str(asisObject *self)
{ {
return psycopg_ensure_text(asis_getquoted(self, NULL)); return psyco_ensure_text(asis_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -132,7 +132,7 @@ binary_getquoted(binaryObject *self, PyObject *args)
static PyObject * static PyObject *
binary_str(binaryObject *self) binary_str(binaryObject *self)
{ {
return psycopg_ensure_text(binary_getquoted(self, NULL)); return psyco_ensure_text(binary_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -36,7 +36,7 @@
RAISES_NEG int RAISES_NEG int
psyco_adapter_datetime_init(void) adapter_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;
@ -76,7 +76,7 @@ _pydatetime_string_date_time(pydatetimeObject *self)
break; break;
} }
if (!(iso = psycopg_ensure_bytes( if (!(iso = psyco_ensure_bytes(
PyObject_CallMethod(self->wrapped, "isoformat", NULL)))) { PyObject_CallMethod(self->wrapped, "isoformat", NULL)))) {
goto error; goto error;
} }
@ -126,7 +126,7 @@ pydatetime_getquoted(pydatetimeObject *self, PyObject *args)
static PyObject * static PyObject *
pydatetime_str(pydatetimeObject *self) pydatetime_str(pydatetimeObject *self)
{ {
return psycopg_ensure_text(pydatetime_getquoted(self, NULL)); return psyco_ensure_text(pydatetime_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -45,7 +45,7 @@ typedef struct {
} pydatetimeObject; } pydatetimeObject;
RAISES_NEG HIDDEN int psyco_adapter_datetime_init(void); RAISES_NEG HIDDEN int adapter_datetime_init(void);
HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args); HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args);
#define psyco_Date_doc \ #define psyco_Date_doc \

View File

@ -165,7 +165,7 @@ exit:
static PyObject * static PyObject *
list_str(listObject *self) list_str(listObject *self)
{ {
return psycopg_ensure_text(list_quote(self)); return psyco_ensure_text(list_quote(self));
} }
static PyObject * static PyObject *

View File

@ -48,7 +48,7 @@ pboolean_getquoted(pbooleanObject *self, PyObject *args)
static PyObject * static PyObject *
pboolean_str(pbooleanObject *self) pboolean_str(pbooleanObject *self)
{ {
return psycopg_ensure_text(pboolean_getquoted(self, NULL)); return psyco_ensure_text(pboolean_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -113,7 +113,7 @@ end:
static PyObject * static PyObject *
pdecimal_str(pdecimalObject *self) pdecimal_str(pdecimalObject *self)
{ {
return psycopg_ensure_text(pdecimal_getquoted(self, NULL)); return psyco_ensure_text(pdecimal_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -86,7 +86,7 @@ exit:
static PyObject * static PyObject *
pfloat_str(pfloatObject *self) pfloat_str(pfloatObject *self)
{ {
return psycopg_ensure_text(pfloat_getquoted(self, NULL)); return psyco_ensure_text(pfloat_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -91,7 +91,7 @@ exit:
static PyObject * static PyObject *
pint_str(pintObject *self) pint_str(pintObject *self)
{ {
return psycopg_ensure_text(pint_getquoted(self, NULL)); return psyco_ensure_text(pint_getquoted(self, NULL));
} }
static PyObject * static PyObject *

View File

@ -73,7 +73,7 @@ qstring_quote(qstringObject *self)
/* encode the string into buffer */ /* encode the string into buffer */
Bytes_AsStringAndSize(str, &s, &len); Bytes_AsStringAndSize(str, &s, &len);
if (!(buffer = psycopg_escape_string(self->conn, s, len, NULL, &qlen))) { if (!(buffer = psyco_escape_string(self->conn, s, len, NULL, &qlen))) {
goto exit; goto exit;
} }
@ -107,7 +107,7 @@ qstring_getquoted(qstringObject *self, PyObject *args)
static PyObject * static PyObject *
qstring_str(qstringObject *self) qstring_str(qstringObject *self)
{ {
return psycopg_ensure_text(qstring_getquoted(self, NULL)); return psyco_ensure_text(qstring_getquoted(self, NULL));
} }
static PyObject * static PyObject *
@ -161,9 +161,9 @@ qstring_set_encoding(qstringObject *self, PyObject *pyenc)
/* get a C copy of the encoding (which may come from unicode) */ /* get a C copy of the encoding (which may come from unicode) */
Py_INCREF(pyenc); Py_INCREF(pyenc);
if (!(pyenc = psycopg_ensure_bytes(pyenc))) { goto exit; } if (!(pyenc = psyco_ensure_bytes(pyenc))) { goto exit; }
if (!(tmp = Bytes_AsString(pyenc))) { goto exit; } if (!(tmp = Bytes_AsString(pyenc))) { goto exit; }
if (0 > psycopg_strdup(&cenc, tmp, -1)) { goto exit; } if (0 > psyco_strdup(&cenc, tmp, -1)) { goto exit; }
Dprintf("qstring_set_encoding: encoding set to %s", cenc); Dprintf("qstring_set_encoding: encoding set to %s", cenc);
PyMem_Free((void *)self->encoding); PyMem_Free((void *)self->encoding);

View File

@ -79,7 +79,7 @@ const int SRV_STATE_UNCHANGED = -1;
PyObject * PyObject *
conn_text_from_chars(connectionObject *self, const char *str) conn_text_from_chars(connectionObject *self, const char *str)
{ {
return psycopg_text_from_chars_safe(str, -1, self ? self->pydecoder : NULL); return psyco_text_from_chars_safe(str, -1, self ? self->pydecoder : NULL);
} }
@ -478,7 +478,7 @@ conn_get_python_codec(const char *encoding,
/* get the Python name of the encoding as a C string */ /* get the Python name of the encoding as a C string */
if (!(encname = conn_pgenc_to_pyenc(encoding, &pgenc))) { goto exit; } if (!(encname = conn_pgenc_to_pyenc(encoding, &pgenc))) { goto exit; }
if (!(encname = psycopg_ensure_bytes(encname))) { goto exit; } if (!(encname = psyco_ensure_bytes(encname))) { goto exit; }
/* Look up the codec functions */ /* Look up the codec functions */
if (!(enc_tmp = PyCodec_Encoder(Bytes_AS_STRING(encname)))) { goto exit; } if (!(enc_tmp = PyCodec_Encoder(Bytes_AS_STRING(encname)))) { goto exit; }
@ -1424,7 +1424,7 @@ conn_tpc_command(connectionObject *self, const char *cmd, xidObject *xid)
Dprintf("conn_tpc_command: %s", cmd); Dprintf("conn_tpc_command: %s", cmd);
/* convert the xid into PostgreSQL transaction id while keeping the GIL */ /* convert the xid into PostgreSQL transaction id while keeping the GIL */
if (!(tid = psycopg_ensure_bytes(xid_get_tid(xid)))) { goto exit; } if (!(tid = psyco_ensure_bytes(xid_get_tid(xid)))) { goto exit; }
if (!(ctid = Bytes_AsString(tid))) { goto exit; } if (!(ctid = Bytes_AsString(tid))) { goto exit; }
Py_BEGIN_ALLOW_THREADS; Py_BEGIN_ALLOW_THREADS;

View File

@ -112,10 +112,10 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *kwargs)
goto exit; goto exit;
} }
if (0 > psyco_curs_withhold_set((cursorObject *)obj, withhold)) { if (0 > curs_withhold_set((cursorObject *)obj, withhold)) {
goto exit; goto exit;
} }
if (0 > psyco_curs_scrollable_set((cursorObject *)obj, scrollable)) { if (0 > curs_scrollable_set((cursorObject *)obj, scrollable)) {
goto exit; goto exit;
} }
@ -478,7 +478,7 @@ _psyco_conn_parse_isolevel(PyObject *pyval)
/* parse from the string -- this includes "default" */ /* parse from the string -- this includes "default" */
else { else {
if (!(pyval = psycopg_ensure_bytes(pyval))) { if (!(pyval = psyco_ensure_bytes(pyval))) {
goto exit; goto exit;
} }
for (level = 1; level <= 4; level++) { for (level = 1; level <= 4; level++) {
@ -516,7 +516,7 @@ _psyco_conn_parse_onoff(PyObject *pyval)
rv = STATE_DEFAULT; rv = STATE_DEFAULT;
} }
else if (PyUnicode_CheckExact(pyval) || Bytes_CheckExact(pyval)) { else if (PyUnicode_CheckExact(pyval) || Bytes_CheckExact(pyval)) {
if (!(pyval = psycopg_ensure_bytes(pyval))) { if (!(pyval = psyco_ensure_bytes(pyval))) {
goto exit; goto exit;
} }
if (0 == strcasecmp("default", Bytes_AS_STRING(pyval))) { if (0 == strcasecmp("default", Bytes_AS_STRING(pyval))) {
@ -918,7 +918,7 @@ psyco_conn_get_dsn_parameters(connectionObject *self, PyObject *dummy)
goto exit; goto exit;
} }
res = psycopg_dict_from_conninfo_options(options, /* include_password = */ 0); res = psyco_dict_from_conninfo_options(options, /* include_password = */ 0);
exit: exit:
PQconninfoFree(options); PQconninfoFree(options);
@ -1314,7 +1314,7 @@ obscure_password(connectionObject *conn)
return 0; return 0;
} }
if (!(d = psycopg_dict_from_conninfo_options( if (!(d = psyco_dict_from_conninfo_options(
options, /* include_password = */ 1))) { options, /* include_password = */ 1))) {
goto exit; goto exit;
} }
@ -1327,12 +1327,12 @@ obscure_password(connectionObject *conn)
/* scrub the password and put back the connection string together */ /* scrub the password and put back the connection string together */
if (!(v = Text_FromUTF8("xxx"))) { goto exit; } if (!(v = Text_FromUTF8("xxx"))) { goto exit; }
if (0 > PyDict_SetItemString(d, "password", v)) { goto exit; } if (0 > PyDict_SetItemString(d, "password", v)) { goto exit; }
if (!(dsn = psycopg_make_dsn(Py_None, d))) { goto exit; } if (!(dsn = psyco_make_dsn(Py_None, d))) { goto exit; }
if (!(dsn = psycopg_ensure_bytes(dsn))) { goto exit; } if (!(dsn = psyco_ensure_bytes(dsn))) { goto exit; }
/* Replace the connection string on the connection object */ /* Replace the connection string on the connection object */
tmp = conn->dsn; tmp = conn->dsn;
psycopg_strdup(&conn->dsn, Bytes_AS_STRING(dsn), -1); psyco_strdup(&conn->dsn, Bytes_AS_STRING(dsn), -1);
PyMem_Free(tmp); PyMem_Free(tmp);
rv = 0; rv = 0;
@ -1356,7 +1356,7 @@ connection_setup(connectionObject *self, const char *dsn, long int async)
self, async, Py_REFCNT(self) self, async, Py_REFCNT(self)
); );
if (0 > psycopg_strdup(&self->dsn, dsn, -1)) { goto exit; } if (0 > psyco_strdup(&self->dsn, dsn, -1)) { goto exit; }
if (!(self->notice_list = PyList_New(0))) { goto exit; } if (!(self->notice_list = PyList_New(0))) { goto exit; }
if (!(self->notifies = PyList_New(0))) { goto exit; } if (!(self->notifies = PyList_New(0))) { goto exit; }
self->async = async; self->async = async;

View File

@ -193,7 +193,7 @@ dsn_parameters_get(connInfoObject *self)
goto exit; goto exit;
} }
res = psycopg_dict_from_conninfo_options(options, /* include_password = */ 0); res = psyco_dict_from_conninfo_options(options, /* include_password = */ 0);
exit: exit:
PQconninfoFree(options); PQconninfoFree(options);

View File

@ -93,9 +93,9 @@ struct cursorObject {
/* C-callable functions in cursor_int.c and cursor_type.c */ /* C-callable functions in cursor_int.c and cursor_type.c */
BORROWED HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid); BORROWED HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid);
HIDDEN void curs_reset(cursorObject *self); HIDDEN void curs_reset(cursorObject *self);
RAISES_NEG HIDDEN int psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue); RAISES_NEG HIDDEN int curs_withhold_set(cursorObject *self, PyObject *pyvalue);
RAISES_NEG HIDDEN int psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue); RAISES_NEG HIDDEN int curs_scrollable_set(cursorObject *self, PyObject *pyvalue);
HIDDEN PyObject *psyco_curs_validate_sql_basic(cursorObject *self, PyObject *sql); HIDDEN PyObject *curs_validate_sql_basic(cursorObject *self, PyObject *sql);
HIDDEN void curs_set_result(cursorObject *self, PGresult *pgres); HIDDEN void curs_set_result(cursorObject *self, PGresult *pgres);
/* exception-raising macros */ /* exception-raising macros */

View File

@ -108,7 +108,7 @@ exit:
* after having set an exception. * after having set an exception.
*/ */
PyObject * PyObject *
psyco_curs_validate_sql_basic(cursorObject *self, PyObject *sql) curs_validate_sql_basic(cursorObject *self, PyObject *sql)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
PyObject *comp = NULL; PyObject *comp = NULL;

View File

@ -43,11 +43,11 @@
/* close method - close the cursor */ /* close method - close the cursor */
#define psyco_curs_close_doc \ #define curs_close_doc \
"close() -- Close the cursor." "close() -- Close the cursor."
static PyObject * static PyObject *
psyco_curs_close(cursorObject *self, PyObject *dummy) curs_close(cursorObject *self, PyObject *dummy)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
char *lname = NULL; char *lname = NULL;
@ -86,7 +86,7 @@ psyco_curs_close(cursorObject *self, PyObject *dummy)
* closing it (the view exists since PG 8.2 according to docs). * closing it (the view exists since PG 8.2 according to docs).
*/ */
if (!self->query && self->conn->server_version >= 80200) { if (!self->query && self->conn->server_version >= 80200) {
if (!(lname = psycopg_escape_string( if (!(lname = psyco_escape_string(
self->conn, self->name, -1, NULL, NULL))) { self->conn, self->name, -1, NULL, NULL))) {
goto exit; goto exit;
} }
@ -110,7 +110,7 @@ close:
CLEARPGRES(self->pgres); CLEARPGRES(self->pgres);
self->closed = 1; self->closed = 1;
Dprintf("psyco_curs_close: cursor at %p closed", self); Dprintf("curs_close: cursor at %p closed", self);
rv = Py_None; rv = Py_None;
Py_INCREF(rv); Py_INCREF(rv);
@ -335,7 +335,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
PyErr_Fetch(&err, &arg, &trace); PyErr_Fetch(&err, &arg, &trace);
if (err && PyErr_GivenExceptionMatches(err, PyExc_TypeError)) { if (err && PyErr_GivenExceptionMatches(err, PyExc_TypeError)) {
Dprintf("psyco_curs_execute: TypeError exception caught"); Dprintf("curs_execute: TypeError exception caught");
PyErr_NormalizeException(&err, &arg, &trace); PyErr_NormalizeException(&err, &arg, &trace);
if (PyObject_HasAttrString(arg, "args")) { if (PyObject_HasAttrString(arg, "args")) {
@ -343,11 +343,11 @@ _psyco_curs_merge_query_args(cursorObject *self,
PyObject *str = PySequence_GetItem(args, 0); PyObject *str = PySequence_GetItem(args, 0);
const char *s = Bytes_AS_STRING(str); const char *s = Bytes_AS_STRING(str);
Dprintf("psyco_curs_execute: -> %s", s); Dprintf("curs_execute: -> %s", s);
if (!strcmp(s, "not enough arguments for format string") if (!strcmp(s, "not enough arguments for format string")
|| !strcmp(s, "not all arguments converted")) { || !strcmp(s, "not all arguments converted")) {
Dprintf("psyco_curs_execute: -> got a match"); Dprintf("curs_execute: -> got a match");
psyco_set_error(ProgrammingError, self, s); psyco_set_error(ProgrammingError, self, s);
pe = 1; pe = 1;
} }
@ -369,7 +369,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
return fquery; return fquery;
} }
#define psyco_curs_execute_doc \ #define curs_execute_doc \
"execute(query, vars=None) -- Execute query with bound vars." "execute(query, vars=None) -- Execute query with bound vars."
RAISES_NEG static int RAISES_NEG static int
@ -382,13 +382,13 @@ _psyco_curs_execute(cursorObject *self,
PyObject *fquery = NULL, *cvt = NULL; PyObject *fquery = NULL, *cvt = NULL;
/* query becomes NULL or refcount +1, so good to XDECREF at the end */ /* query becomes NULL or refcount +1, so good to XDECREF at the end */
if (!(query = psyco_curs_validate_sql_basic(self, query))) { if (!(query = curs_validate_sql_basic(self, query))) {
goto exit; goto exit;
} }
CLEARPGRES(self->pgres); CLEARPGRES(self->pgres);
Py_CLEAR(self->query); Py_CLEAR(self->query);
Dprintf("psyco_curs_execute: starting execution of new query"); Dprintf("curs_execute: starting execution of new query");
/* here we are, and we have a sequence or a dictionary filled with /* here we are, and we have a sequence or a dictionary filled with
objects to be substituted (bound variables). we try to be smart and do objects to be substituted (bound variables). we try to be smart and do
@ -444,7 +444,7 @@ _psyco_curs_execute(cursorObject *self,
/* At this point, the SQL statement must be str, not unicode */ /* At this point, the SQL statement must be str, not unicode */
tmp = pq_execute(self, Bytes_AS_STRING(self->query), async, no_result, 0); tmp = pq_execute(self, Bytes_AS_STRING(self->query), async, no_result, 0);
Dprintf("psyco_curs_execute: res = %d, pgres = %p", tmp, self->pgres); Dprintf("curs_execute: res = %d, pgres = %p", tmp, self->pgres);
if (tmp < 0) { goto exit; } if (tmp < 0) { goto exit; }
res = 0; /* Success */ res = 0; /* Success */
@ -458,7 +458,7 @@ exit:
} }
static PyObject * static PyObject *
psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs) curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *vars = NULL, *operation = NULL; PyObject *vars = NULL, *operation = NULL;
@ -495,11 +495,11 @@ psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
#define psyco_curs_executemany_doc \ #define curs_executemany_doc \
"executemany(query, vars_list) -- Execute many queries with bound vars." "executemany(query, vars_list) -- Execute many queries with bound vars."
static PyObject * static PyObject *
psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *operation = NULL, *vars = NULL; PyObject *operation = NULL, *vars = NULL;
PyObject *v, *iter = NULL; PyObject *v, *iter = NULL;
@ -556,7 +556,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
} }
#define psyco_curs_mogrify_doc \ #define curs_mogrify_doc \
"mogrify(query, vars=None) -> str -- Return query after vars binding." "mogrify(query, vars=None) -> str -- Return query after vars binding."
static PyObject * static PyObject *
@ -565,10 +565,10 @@ _psyco_curs_mogrify(cursorObject *self,
{ {
PyObject *fquery = NULL, *cvt = NULL; PyObject *fquery = NULL, *cvt = NULL;
operation = psyco_curs_validate_sql_basic(self, operation); operation = curs_validate_sql_basic(self, operation);
if (operation == NULL) { goto cleanup; } if (operation == NULL) { goto cleanup; }
Dprintf("psyco_curs_mogrify: starting mogrify"); Dprintf("curs_mogrify: starting mogrify");
/* here we are, and we have a sequence or a dictionary filled with /* here we are, and we have a sequence or a dictionary filled with
objects to be substituted (bound variables). we try to be smart and do objects to be substituted (bound variables). we try to be smart and do
@ -586,7 +586,7 @@ _psyco_curs_mogrify(cursorObject *self,
goto cleanup; goto cleanup;
} }
Dprintf("psyco_curs_mogrify: cvt->refcnt = " FORMAT_CODE_PY_SSIZE_T Dprintf("curs_mogrify: cvt->refcnt = " FORMAT_CODE_PY_SSIZE_T
", fquery->refcnt = " FORMAT_CODE_PY_SSIZE_T, ", fquery->refcnt = " FORMAT_CODE_PY_SSIZE_T,
Py_REFCNT(cvt), Py_REFCNT(fquery)); Py_REFCNT(cvt), Py_REFCNT(fquery));
} }
@ -603,7 +603,7 @@ cleanup:
} }
static PyObject * static PyObject *
psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs) curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *vars = NULL, *operation = NULL; PyObject *vars = NULL, *operation = NULL;
@ -619,7 +619,7 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
/* cast method - convert an oid/string into a Python object */ /* cast method - convert an oid/string into a Python object */
#define psyco_curs_cast_doc \ #define curs_cast_doc \
"cast(oid, s) -> value\n\n" \ "cast(oid, s) -> value\n\n" \
"Convert the string s to a Python object according to its oid.\n\n" \ "Convert the string s to a Python object according to its oid.\n\n" \
"Look for a typecaster first in the cursor, then in its connection," \ "Look for a typecaster first in the cursor, then in its connection," \
@ -627,7 +627,7 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
"leave the value as a string." "leave the value as a string."
static PyObject * static PyObject *
psyco_curs_cast(cursorObject *self, PyObject *args) curs_cast(cursorObject *self, PyObject *args)
{ {
PyObject *oid; PyObject *oid;
PyObject *s; PyObject *s;
@ -643,7 +643,7 @@ psyco_curs_cast(cursorObject *self, PyObject *args)
/* fetchone method - fetch one row of results */ /* fetchone method - fetch one row of results */
#define psyco_curs_fetchone_doc \ #define curs_fetchone_doc \
"fetchone() -> tuple or None\n\n" \ "fetchone() -> tuple or None\n\n" \
"Return the next row of a query result set in the form of a tuple (by\n" \ "Return the next row of a query result set in the form of a tuple (by\n" \
"default) or using the sequence factory previously set in the\n" \ "default) or using the sequence factory previously set in the\n" \
@ -744,7 +744,7 @@ exit:
} }
static PyObject * static PyObject *
psyco_curs_fetchone(cursorObject *self, PyObject *dummy) curs_fetchone(cursorObject *self, PyObject *dummy)
{ {
PyObject *res; PyObject *res;
@ -763,8 +763,8 @@ psyco_curs_fetchone(cursorObject *self, PyObject *dummy)
if (_psyco_curs_prefetch(self) < 0) return NULL; if (_psyco_curs_prefetch(self) < 0) return NULL;
} }
Dprintf("psyco_curs_fetchone: fetching row %ld", self->row); Dprintf("curs_fetchone: fetching row %ld", self->row);
Dprintf("psyco_curs_fetchone: rowcount = %ld", self->rowcount); Dprintf("curs_fetchone: rowcount = %ld", self->rowcount);
if (self->row >= self->rowcount) { if (self->row >= self->rowcount) {
/* we exausted available data: return None */ /* we exausted available data: return None */
@ -789,11 +789,11 @@ psyco_curs_fetchone(cursorObject *self, PyObject *dummy)
* Fetch several records at time. Return NULL when the cursor is exhausted. * Fetch several records at time. Return NULL when the cursor is exhausted.
*/ */
static PyObject * static PyObject *
psyco_curs_next_named(cursorObject *self) curs_next_named(cursorObject *self)
{ {
PyObject *res; PyObject *res;
Dprintf("psyco_curs_next_named"); Dprintf("curs_next_named");
EXC_IF_CURS_CLOSED(self); EXC_IF_CURS_CLOSED(self);
EXC_IF_ASYNC_IN_PROGRESS(self, next); EXC_IF_ASYNC_IN_PROGRESS(self, next);
if (_psyco_curs_prefetch(self) < 0) return NULL; if (_psyco_curs_prefetch(self) < 0) return NULL;
@ -802,8 +802,8 @@ psyco_curs_next_named(cursorObject *self)
EXC_IF_NO_MARK(self); EXC_IF_NO_MARK(self);
EXC_IF_TPC_PREPARED(self->conn, next); EXC_IF_TPC_PREPARED(self->conn, next);
Dprintf("psyco_curs_next_named: row %ld", self->row); Dprintf("curs_next_named: row %ld", self->row);
Dprintf("psyco_curs_next_named: rowcount = %ld", self->rowcount); Dprintf("curs_next_named: rowcount = %ld", self->rowcount);
if (self->row >= self->rowcount) { if (self->row >= self->rowcount) {
char buffer[128]; char buffer[128];
@ -834,7 +834,7 @@ psyco_curs_next_named(cursorObject *self)
/* fetch many - fetch some results */ /* fetch many - fetch some results */
#define psyco_curs_fetchmany_doc \ #define curs_fetchmany_doc \
"fetchmany(size=self.arraysize) -> list of tuple\n\n" \ "fetchmany(size=self.arraysize) -> list of tuple\n\n" \
"Return the next `size` rows of a query result set in the form of a list\n" \ "Return the next `size` rows of a query result set in the form of a list\n" \
"of tuples (by default) or using the sequence factory previously set in\n" \ "of tuples (by default) or using the sequence factory previously set in\n" \
@ -842,7 +842,7 @@ psyco_curs_next_named(cursorObject *self)
"Return an empty list when no more data is available.\n" "Return an empty list when no more data is available.\n"
static PyObject * static PyObject *
psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords) curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords)
{ {
int i; int i;
PyObject *list = NULL; PyObject *list = NULL;
@ -887,7 +887,7 @@ psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords)
size = self->rowcount - self->row; size = self->rowcount - self->row;
} }
Dprintf("psyco_curs_fetchmany: size = %ld", size); Dprintf("curs_fetchmany: size = %ld", size);
if (size <= 0) { if (size <= 0) {
rv = PyList_New(0); rv = PyList_New(0);
@ -927,7 +927,7 @@ exit:
/* fetch all - fetch all results */ /* fetch all - fetch all results */
#define psyco_curs_fetchall_doc \ #define curs_fetchall_doc \
"fetchall() -> list of tuple\n\n" \ "fetchall() -> list of tuple\n\n" \
"Return all the remaining rows of a query result set.\n\n" \ "Return all the remaining rows of a query result set.\n\n" \
"Rows are returned in the form of a list of tuples (by default) or using\n" \ "Rows are returned in the form of a list of tuples (by default) or using\n" \
@ -935,7 +935,7 @@ exit:
"Return `!None` when no more data is available.\n" "Return `!None` when no more data is available.\n"
static PyObject * static PyObject *
psyco_curs_fetchall(cursorObject *self, PyObject *dummy) curs_fetchall(cursorObject *self, PyObject *dummy)
{ {
int i, size; int i, size;
PyObject *list = NULL; PyObject *list = NULL;
@ -996,11 +996,11 @@ exit:
/* callproc method - execute a stored procedure */ /* callproc method - execute a stored procedure */
#define psyco_curs_callproc_doc \ #define curs_callproc_doc \
"callproc(procname, parameters=None) -- Execute stored procedure." "callproc(procname, parameters=None) -- Execute stored procedure."
static PyObject * static PyObject *
psyco_curs_callproc(cursorObject *self, PyObject *args) curs_callproc(cursorObject *self, PyObject *args)
{ {
const char *procname = NULL; const char *procname = NULL;
char *sql = NULL; char *sql = NULL;
@ -1059,10 +1059,10 @@ psyco_curs_callproc(cursorObject *self, PyObject *args)
Py_INCREF(pname); /* was borrowed */ Py_INCREF(pname); /* was borrowed */
/* this also makes a check for keys being strings */ /* this also makes a check for keys being strings */
if (!(pname = psycopg_ensure_bytes(pname))) { goto exit; } if (!(pname = psyco_ensure_bytes(pname))) { goto exit; }
if (!(cpname = Bytes_AsString(pname))) { goto exit; } if (!(cpname = Bytes_AsString(pname))) { goto exit; }
if (!(scpnames[i] = psycopg_escape_identifier( if (!(scpnames[i] = psyco_escape_identifier(
self->conn, cpname, -1))) { self->conn, cpname, -1))) {
Py_CLEAR(pname); Py_CLEAR(pname);
goto exit; goto exit;
@ -1144,13 +1144,13 @@ exit:
/* nextset method - return the next set of data (not supported) */ /* nextset method - return the next set of data (not supported) */
#define psyco_curs_nextset_doc \ #define curs_nextset_doc \
"nextset() -- Skip to next set of data.\n\n" \ "nextset() -- Skip to next set of data.\n\n" \
"This method is not supported (PostgreSQL does not have multiple data \n" \ "This method is not supported (PostgreSQL does not have multiple data \n" \
"sets) and will raise a NotSupportedError exception." "sets) and will raise a NotSupportedError exception."
static PyObject * static PyObject *
psyco_curs_nextset(cursorObject *self, PyObject *dummy) curs_nextset(cursorObject *self, PyObject *dummy)
{ {
EXC_IF_CURS_CLOSED(self); EXC_IF_CURS_CLOSED(self);
@ -1161,12 +1161,12 @@ psyco_curs_nextset(cursorObject *self, PyObject *dummy)
/* setinputsizes - predefine memory areas for execute (does nothing) */ /* setinputsizes - predefine memory areas for execute (does nothing) */
#define psyco_curs_setinputsizes_doc \ #define curs_setinputsizes_doc \
"setinputsizes(sizes) -- Set memory areas before execute.\n\n" \ "setinputsizes(sizes) -- Set memory areas before execute.\n\n" \
"This method currently does nothing but it is safe to call it." "This method currently does nothing but it is safe to call it."
static PyObject * static PyObject *
psyco_curs_setinputsizes(cursorObject *self, PyObject *args) curs_setinputsizes(cursorObject *self, PyObject *args)
{ {
PyObject *sizes; PyObject *sizes;
@ -1181,12 +1181,12 @@ psyco_curs_setinputsizes(cursorObject *self, PyObject *args)
/* setoutputsize - predefine memory areas for execute (does nothing) */ /* setoutputsize - predefine memory areas for execute (does nothing) */
#define psyco_curs_setoutputsize_doc \ #define curs_setoutputsize_doc \
"setoutputsize(size, column=None) -- Set column buffer size.\n\n" \ "setoutputsize(size, column=None) -- Set column buffer size.\n\n" \
"This method currently does nothing but it is safe to call it." "This method currently does nothing but it is safe to call it."
static PyObject * static PyObject *
psyco_curs_setoutputsize(cursorObject *self, PyObject *args) curs_setoutputsize(cursorObject *self, PyObject *args)
{ {
long int size, column; long int size, column;
@ -1201,11 +1201,11 @@ psyco_curs_setoutputsize(cursorObject *self, PyObject *args)
/* scroll - scroll position in result list */ /* scroll - scroll position in result list */
#define psyco_curs_scroll_doc \ #define curs_scroll_doc \
"scroll(value, mode='relative') -- Scroll to new position according to mode." "scroll(value, mode='relative') -- Scroll to new position according to mode."
static PyObject * static PyObject *
psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs) curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
int value, newpos; int value, newpos;
const char *mode = "relative"; const char *mode = "relative";
@ -1263,21 +1263,21 @@ psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
} }
#define psyco_curs_enter_doc \ #define curs_enter_doc \
"__enter__ -> self" "__enter__ -> self"
static PyObject * static PyObject *
psyco_curs_enter(cursorObject *self, PyObject *dummy) curs_enter(cursorObject *self, PyObject *dummy)
{ {
Py_INCREF(self); Py_INCREF(self);
return (PyObject *)self; return (PyObject *)self;
} }
#define psyco_curs_exit_doc \ #define curs_exit_doc \
"__exit__ -- close the cursor" "__exit__ -- close the cursor"
static PyObject * static PyObject *
psyco_curs_exit(cursorObject *self, PyObject *args) curs_exit(cursorObject *self, PyObject *args)
{ {
PyObject *tmp = NULL; PyObject *tmp = NULL;
PyObject *rv = NULL; PyObject *rv = NULL;
@ -1332,7 +1332,7 @@ static char *_psyco_curs_copy_columns(PyObject *columns)
columnlist[0] = '('; columnlist[0] = '(';
while ((col = PyIter_Next(coliter)) != NULL) { while ((col = PyIter_Next(coliter)) != NULL) {
if (!(col = psycopg_ensure_bytes(col))) { if (!(col = psyco_ensure_bytes(col))) {
Py_DECREF(coliter); Py_DECREF(coliter);
goto error; goto error;
} }
@ -1379,11 +1379,11 @@ exit:
/* extension: copy_from - implements COPY FROM */ /* extension: copy_from - implements COPY FROM */
#define psyco_curs_copy_from_doc \ #define curs_copy_from_doc \
"copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None) -- Copy table from file." "copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None) -- Copy table from file."
static PyObject * static PyObject *
psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
static char *kwlist[] = { static char *kwlist[] = {
"file", "table", "sep", "null", "size", "columns", NULL}; "file", "table", "sep", "null", "size", "columns", NULL};
@ -1423,12 +1423,12 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
if (NULL == (columnlist = _psyco_curs_copy_columns(columns))) if (NULL == (columnlist = _psyco_curs_copy_columns(columns)))
goto exit; goto exit;
if (!(quoted_delimiter = psycopg_escape_string( if (!(quoted_delimiter = psyco_escape_string(
self->conn, sep, -1, NULL, NULL))) { self->conn, sep, -1, NULL, NULL))) {
goto exit; goto exit;
} }
if (!(quoted_null = psycopg_escape_string( if (!(quoted_null = psyco_escape_string(
self->conn, null, -1, NULL, NULL))) { self->conn, null, -1, NULL, NULL))) {
goto exit; goto exit;
} }
@ -1443,10 +1443,10 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
PyOS_snprintf(query, query_size, command, PyOS_snprintf(query, query_size, command,
table_name, columnlist, quoted_delimiter, quoted_null); table_name, columnlist, quoted_delimiter, quoted_null);
Dprintf("psyco_curs_copy_from: query = %s", query); Dprintf("curs_copy_from: query = %s", query);
/* This routine stores a borrowed reference. Although it is only held /* This routine stores a borrowed reference. Although it is only held
* for the duration of psyco_curs_copy_from, nested invocations of * for the duration of curs_copy_from, nested invocations of
* Py_BEGIN_ALLOW_THREADS could surrender control to another thread, * Py_BEGIN_ALLOW_THREADS could surrender control to another thread,
* which could invoke the garbage collector. We thus need an * which could invoke the garbage collector. We thus need an
* INCREF/DECREF pair if we store this pointer in a GC object, such as * INCREF/DECREF pair if we store this pointer in a GC object, such as
@ -1473,11 +1473,11 @@ exit:
/* extension: copy_to - implements COPY TO */ /* extension: copy_to - implements COPY TO */
#define psyco_curs_copy_to_doc \ #define curs_copy_to_doc \
"copy_to(file, table, sep='\\t', null='\\\\N', columns=None) -- Copy table to file." "copy_to(file, table, sep='\\t', null='\\\\N', columns=None) -- Copy table to file."
static PyObject * static PyObject *
psyco_curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
static char *kwlist[] = {"file", "table", "sep", "null", "columns", NULL}; static char *kwlist[] = {"file", "table", "sep", "null", "columns", NULL};
@ -1515,12 +1515,12 @@ psyco_curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
if (NULL == (columnlist = _psyco_curs_copy_columns(columns))) if (NULL == (columnlist = _psyco_curs_copy_columns(columns)))
goto exit; goto exit;
if (!(quoted_delimiter = psycopg_escape_string( if (!(quoted_delimiter = psyco_escape_string(
self->conn, sep, -1, NULL, NULL))) { self->conn, sep, -1, NULL, NULL))) {
goto exit; goto exit;
} }
if (!(quoted_null = psycopg_escape_string( if (!(quoted_null = psyco_escape_string(
self->conn, null, -1, NULL, NULL))) { self->conn, null, -1, NULL, NULL))) {
goto exit; goto exit;
} }
@ -1535,7 +1535,7 @@ psyco_curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
PyOS_snprintf(query, query_size, command, PyOS_snprintf(query, query_size, command,
table_name, columnlist, quoted_delimiter, quoted_null); table_name, columnlist, quoted_delimiter, quoted_null);
Dprintf("psyco_curs_copy_to: query = %s", query); Dprintf("curs_copy_to: query = %s", query);
self->copysize = 0; self->copysize = 0;
Py_INCREF(file); Py_INCREF(file);
@ -1563,7 +1563,7 @@ exit:
SQL statement, rather than composing the statement from parameters. SQL statement, rather than composing the statement from parameters.
*/ */
#define psyco_curs_copy_expert_doc \ #define curs_copy_expert_doc \
"copy_expert(sql, file, size=8192) -- Submit a user-composed COPY statement.\n" \ "copy_expert(sql, file, size=8192) -- Submit a user-composed COPY statement.\n" \
"`file` must be an open, readable file for COPY FROM or an open, writable\n" \ "`file` must be an open, readable file for COPY FROM or an open, writable\n" \
"file for COPY TO. The optional `size` argument, when specified for a COPY\n" \ "file for COPY TO. The optional `size` argument, when specified for a COPY\n" \
@ -1571,7 +1571,7 @@ exit:
"buffer size." "buffer size."
static PyObject * static PyObject *
psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs) curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
{ {
Py_ssize_t bufsize = DEFAULT_COPYBUFF; Py_ssize_t bufsize = DEFAULT_COPYBUFF;
PyObject *sql, *file, *res = NULL; PyObject *sql, *file, *res = NULL;
@ -1587,7 +1587,7 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
EXC_IF_GREEN(copy_expert); EXC_IF_GREEN(copy_expert);
EXC_IF_TPC_PREPARED(self->conn, copy_expert); EXC_IF_TPC_PREPARED(self->conn, copy_expert);
sql = psyco_curs_validate_sql_basic(self, sql); sql = curs_validate_sql_basic(self, sql);
/* Any failure from here forward should 'goto exit' rather than /* Any failure from here forward should 'goto exit' rather than
'return NULL' directly. */ 'return NULL' directly. */
@ -1630,28 +1630,28 @@ exit:
/* extension: closed - return true if cursor is closed */ /* extension: closed - return true if cursor is closed */
#define psyco_curs_closed_doc \ #define curs_closed_doc \
"True if cursor is closed, False if cursor is open" "True if cursor is closed, False if cursor is open"
static PyObject * static PyObject *
psyco_curs_get_closed(cursorObject *self, void *closure) curs_closed_get(cursorObject *self, void *closure)
{ {
return PyBool_FromLong(self->closed || (self->conn && self->conn->closed)); return PyBool_FromLong(self->closed || (self->conn && self->conn->closed));
} }
/* extension: withhold - get or set "WITH HOLD" for named cursors */ /* extension: withhold - get or set "WITH HOLD" for named cursors */
#define psyco_curs_withhold_doc \ #define curs_withhold_doc \
"Set or return cursor use of WITH HOLD" "Set or return cursor use of WITH HOLD"
static PyObject * static PyObject *
psyco_curs_withhold_get(cursorObject *self) curs_withhold_get(cursorObject *self)
{ {
return PyBool_FromLong(self->withhold); return PyBool_FromLong(self->withhold);
} }
RAISES_NEG int RAISES_NEG int
psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue) curs_withhold_set(cursorObject *self, PyObject *pyvalue)
{ {
int value; int value;
@ -1669,11 +1669,11 @@ psyco_curs_withhold_set(cursorObject *self, PyObject *pyvalue)
return 0; return 0;
} }
#define psyco_curs_scrollable_doc \ #define curs_scrollable_doc \
"Set or return cursor use of SCROLL" "Set or return cursor use of SCROLL"
static PyObject * static PyObject *
psyco_curs_scrollable_get(cursorObject *self) curs_scrollable_get(cursorObject *self)
{ {
PyObject *ret = NULL; PyObject *ret = NULL;
@ -1696,7 +1696,7 @@ psyco_curs_scrollable_get(cursorObject *self)
} }
RAISES_NEG int RAISES_NEG int
psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue) curs_scrollable_set(cursorObject *self, PyObject *pyvalue)
{ {
int value; int value;
@ -1718,11 +1718,11 @@ psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue)
} }
#define psyco_curs_pgresult_ptr_doc \ #define curs_pgresult_ptr_doc \
"pgresult_ptr -- Get the PGresult structure pointer." "pgresult_ptr -- Get the PGresult structure pointer."
static PyObject * static PyObject *
psyco_curs_pgresult_ptr_get(cursorObject *self) curs_pgresult_ptr_get(cursorObject *self)
{ {
if (self->pgres) { if (self->pgres) {
return PyLong_FromVoidPtr((void *)self->pgres); return PyLong_FromVoidPtr((void *)self->pgres);
@ -1751,8 +1751,8 @@ cursor_next(PyObject *self)
PyObject *res; PyObject *res;
if (NULL == ((cursorObject*)self)->name) { if (NULL == ((cursorObject*)self)->name) {
/* we don't parse arguments: psyco_curs_fetchone will do that for us */ /* we don't parse arguments: curs_fetchone will do that for us */
res = psyco_curs_fetchone((cursorObject*)self, NULL); res = curs_fetchone((cursorObject*)self, NULL);
/* convert a None to NULL to signal the end of iteration */ /* convert a None to NULL to signal the end of iteration */
if (res && res == Py_None) { if (res && res == Py_None) {
@ -1761,7 +1761,7 @@ cursor_next(PyObject *self)
} }
} }
else { else {
res = psyco_curs_next_named((cursorObject*)self); res = curs_next_named((cursorObject*)self);
} }
return res; return res;
@ -1771,44 +1771,44 @@ cursor_next(PyObject *self)
static struct PyMethodDef cursorObject_methods[] = { static struct PyMethodDef cursorObject_methods[] = {
/* DBAPI-2.0 core */ /* DBAPI-2.0 core */
{"close", (PyCFunction)psyco_curs_close, {"close", (PyCFunction)curs_close,
METH_NOARGS, psyco_curs_close_doc}, METH_NOARGS, curs_close_doc},
{"execute", (PyCFunction)psyco_curs_execute, {"execute", (PyCFunction)curs_execute,
METH_VARARGS|METH_KEYWORDS, psyco_curs_execute_doc}, METH_VARARGS|METH_KEYWORDS, curs_execute_doc},
{"executemany", (PyCFunction)psyco_curs_executemany, {"executemany", (PyCFunction)curs_executemany,
METH_VARARGS|METH_KEYWORDS, psyco_curs_executemany_doc}, METH_VARARGS|METH_KEYWORDS, curs_executemany_doc},
{"fetchone", (PyCFunction)psyco_curs_fetchone, {"fetchone", (PyCFunction)curs_fetchone,
METH_NOARGS, psyco_curs_fetchone_doc}, METH_NOARGS, curs_fetchone_doc},
{"fetchmany", (PyCFunction)psyco_curs_fetchmany, {"fetchmany", (PyCFunction)curs_fetchmany,
METH_VARARGS|METH_KEYWORDS, psyco_curs_fetchmany_doc}, METH_VARARGS|METH_KEYWORDS, curs_fetchmany_doc},
{"fetchall", (PyCFunction)psyco_curs_fetchall, {"fetchall", (PyCFunction)curs_fetchall,
METH_NOARGS, psyco_curs_fetchall_doc}, METH_NOARGS, curs_fetchall_doc},
{"callproc", (PyCFunction)psyco_curs_callproc, {"callproc", (PyCFunction)curs_callproc,
METH_VARARGS, psyco_curs_callproc_doc}, METH_VARARGS, curs_callproc_doc},
{"nextset", (PyCFunction)psyco_curs_nextset, {"nextset", (PyCFunction)curs_nextset,
METH_NOARGS, psyco_curs_nextset_doc}, METH_NOARGS, curs_nextset_doc},
{"setinputsizes", (PyCFunction)psyco_curs_setinputsizes, {"setinputsizes", (PyCFunction)curs_setinputsizes,
METH_VARARGS, psyco_curs_setinputsizes_doc}, METH_VARARGS, curs_setinputsizes_doc},
{"setoutputsize", (PyCFunction)psyco_curs_setoutputsize, {"setoutputsize", (PyCFunction)curs_setoutputsize,
METH_VARARGS, psyco_curs_setoutputsize_doc}, METH_VARARGS, curs_setoutputsize_doc},
/* DBAPI-2.0 extensions */ /* DBAPI-2.0 extensions */
{"scroll", (PyCFunction)psyco_curs_scroll, {"scroll", (PyCFunction)curs_scroll,
METH_VARARGS|METH_KEYWORDS, psyco_curs_scroll_doc}, METH_VARARGS|METH_KEYWORDS, curs_scroll_doc},
{"__enter__", (PyCFunction)psyco_curs_enter, {"__enter__", (PyCFunction)curs_enter,
METH_NOARGS, psyco_curs_enter_doc}, METH_NOARGS, curs_enter_doc},
{"__exit__", (PyCFunction)psyco_curs_exit, {"__exit__", (PyCFunction)curs_exit,
METH_VARARGS, psyco_curs_exit_doc}, METH_VARARGS, curs_exit_doc},
/* psycopg extensions */ /* psycopg extensions */
{"cast", (PyCFunction)psyco_curs_cast, {"cast", (PyCFunction)curs_cast,
METH_VARARGS, psyco_curs_cast_doc}, METH_VARARGS, curs_cast_doc},
{"mogrify", (PyCFunction)psyco_curs_mogrify, {"mogrify", (PyCFunction)curs_mogrify,
METH_VARARGS|METH_KEYWORDS, psyco_curs_mogrify_doc}, METH_VARARGS|METH_KEYWORDS, curs_mogrify_doc},
{"copy_from", (PyCFunction)psyco_curs_copy_from, {"copy_from", (PyCFunction)curs_copy_from,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_from_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_from_doc},
{"copy_to", (PyCFunction)psyco_curs_copy_to, {"copy_to", (PyCFunction)curs_copy_to,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_to_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_to_doc},
{"copy_expert", (PyCFunction)psyco_curs_copy_expert, {"copy_expert", (PyCFunction)curs_copy_expert,
METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_expert_doc}, METH_VARARGS|METH_KEYWORDS, curs_copy_expert_doc},
{NULL} {NULL}
}; };
@ -1849,19 +1849,19 @@ static struct PyMemberDef cursorObject_members[] = {
/* object calculated member list */ /* object calculated member list */
static struct PyGetSetDef cursorObject_getsets[] = { static struct PyGetSetDef cursorObject_getsets[] = {
{ "closed", (getter)psyco_curs_get_closed, NULL, { "closed", (getter)curs_closed_get, NULL,
psyco_curs_closed_doc, NULL }, curs_closed_doc, NULL },
{ "withhold", { "withhold",
(getter)psyco_curs_withhold_get, (getter)curs_withhold_get,
(setter)psyco_curs_withhold_set, (setter)curs_withhold_set,
psyco_curs_withhold_doc, NULL }, curs_withhold_doc, NULL },
{ "scrollable", { "scrollable",
(getter)psyco_curs_scrollable_get, (getter)curs_scrollable_get,
(setter)psyco_curs_scrollable_set, (setter)curs_scrollable_set,
psyco_curs_scrollable_doc, NULL }, curs_scrollable_doc, NULL },
{ "pgresult_ptr", { "pgresult_ptr",
(getter)psyco_curs_pgresult_ptr_get, NULL, (getter)curs_pgresult_ptr_get, NULL,
psyco_curs_pgresult_ptr_doc, NULL }, curs_pgresult_ptr_doc, NULL },
{NULL} {NULL}
}; };
@ -1874,10 +1874,10 @@ cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
Dprintf("cursor_setup: parameters: name = %s, conn = %p", name, conn); Dprintf("cursor_setup: parameters: name = %s, conn = %p", name, conn);
if (name) { if (name) {
if (0 > psycopg_strdup(&self->name, name, -1)) { if (0 > psyco_strdup(&self->name, name, -1)) {
return -1; return -1;
} }
if (!(self->qname = psycopg_escape_identifier(conn, name, -1))) { if (!(self->qname = psyco_escape_identifier(conn, name, -1))) {
return -1; return -1;
} }
} }
@ -1982,7 +1982,7 @@ cursor_init(PyObject *obj, PyObject *args, PyObject *kwargs)
if (name != Py_None) { if (name != Py_None) {
Py_INCREF(name); /* for ensure_bytes */ Py_INCREF(name); /* for ensure_bytes */
if (!(bname = psycopg_ensure_bytes(name))) { if (!(bname = psyco_ensure_bytes(name))) {
/* name has had a ref stolen */ /* name has had a ref stolen */
goto exit; goto exit;
} }

View File

@ -61,7 +61,7 @@
* If the cursor or its result isn't available, return None. * If the cursor or its result isn't available, return None.
*/ */
static PyObject * static PyObject *
psyco_diagnostics_get_field(diagnosticsObject *self, void *closure) diagnostics_get_field(diagnosticsObject *self, void *closure)
{ {
const char *errortext; const char *errortext;
@ -76,41 +76,41 @@ psyco_diagnostics_get_field(diagnosticsObject *self, void *closure)
/* object calculated member list */ /* object calculated member list */
static struct PyGetSetDef diagnosticsObject_getsets[] = { static struct PyGetSetDef diagnosticsObject_getsets[] = {
{ "severity", (getter)psyco_diagnostics_get_field, NULL, { "severity", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SEVERITY }, NULL, (void*) PG_DIAG_SEVERITY },
{ "severity_nonlocalized", (getter)psyco_diagnostics_get_field, NULL, { "severity_nonlocalized", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SEVERITY_NONLOCALIZED }, NULL, (void*) PG_DIAG_SEVERITY_NONLOCALIZED },
{ "sqlstate", (getter)psyco_diagnostics_get_field, NULL, { "sqlstate", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SQLSTATE }, NULL, (void*) PG_DIAG_SQLSTATE },
{ "message_primary", (getter)psyco_diagnostics_get_field, NULL, { "message_primary", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_PRIMARY }, NULL, (void*) PG_DIAG_MESSAGE_PRIMARY },
{ "message_detail", (getter)psyco_diagnostics_get_field, NULL, { "message_detail", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_DETAIL }, NULL, (void*) PG_DIAG_MESSAGE_DETAIL },
{ "message_hint", (getter)psyco_diagnostics_get_field, NULL, { "message_hint", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_MESSAGE_HINT }, NULL, (void*) PG_DIAG_MESSAGE_HINT },
{ "statement_position", (getter)psyco_diagnostics_get_field, NULL, { "statement_position", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_STATEMENT_POSITION }, NULL, (void*) PG_DIAG_STATEMENT_POSITION },
{ "internal_position", (getter)psyco_diagnostics_get_field, NULL, { "internal_position", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_INTERNAL_POSITION }, NULL, (void*) PG_DIAG_INTERNAL_POSITION },
{ "internal_query", (getter)psyco_diagnostics_get_field, NULL, { "internal_query", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_INTERNAL_QUERY }, NULL, (void*) PG_DIAG_INTERNAL_QUERY },
{ "context", (getter)psyco_diagnostics_get_field, NULL, { "context", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_CONTEXT }, NULL, (void*) PG_DIAG_CONTEXT },
{ "schema_name", (getter)psyco_diagnostics_get_field, NULL, { "schema_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SCHEMA_NAME }, NULL, (void*) PG_DIAG_SCHEMA_NAME },
{ "table_name", (getter)psyco_diagnostics_get_field, NULL, { "table_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_TABLE_NAME }, NULL, (void*) PG_DIAG_TABLE_NAME },
{ "column_name", (getter)psyco_diagnostics_get_field, NULL, { "column_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_COLUMN_NAME }, NULL, (void*) PG_DIAG_COLUMN_NAME },
{ "datatype_name", (getter)psyco_diagnostics_get_field, NULL, { "datatype_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_DATATYPE_NAME }, NULL, (void*) PG_DIAG_DATATYPE_NAME },
{ "constraint_name", (getter)psyco_diagnostics_get_field, NULL, { "constraint_name", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_CONSTRAINT_NAME }, NULL, (void*) PG_DIAG_CONSTRAINT_NAME },
{ "source_file", (getter)psyco_diagnostics_get_field, NULL, { "source_file", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_FILE }, NULL, (void*) PG_DIAG_SOURCE_FILE },
{ "source_line", (getter)psyco_diagnostics_get_field, NULL, { "source_line", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_LINE }, NULL, (void*) PG_DIAG_SOURCE_LINE },
{ "source_function", (getter)psyco_diagnostics_get_field, NULL, { "source_function", (getter)diagnostics_get_field, NULL,
NULL, (void*) PG_DIAG_SOURCE_FUNCTION }, NULL, (void*) PG_DIAG_SOURCE_FUNCTION },
{NULL} {NULL}
}; };

View File

@ -34,7 +34,7 @@
PyObject * PyObject *
error_text_from_chars(errorObject *self, const char *str) error_text_from_chars(errorObject *self, const char *str)
{ {
return psycopg_text_from_chars_safe(str, -1, self->pydecoder); return psyco_text_from_chars_safe(str, -1, self->pydecoder);
} }
@ -229,7 +229,7 @@ static struct PyGetSetDef error_getsets[] = {
* would require implementing __getstate__, and as of 2012 it's a little * would require implementing __getstate__, and as of 2012 it's a little
* bit too late to care. */ * bit too late to care. */
static PyObject * static PyObject *
psyco_error_reduce(errorObject *self, PyObject *dummy) error_reduce(errorObject *self, PyObject *dummy)
{ {
PyObject *meth = NULL; PyObject *meth = NULL;
PyObject *tuple = NULL; PyObject *tuple = NULL;
@ -288,7 +288,7 @@ error:
} }
PyObject * PyObject *
psyco_error_setstate(errorObject *self, PyObject *state) error_setstate(errorObject *self, PyObject *state)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
@ -326,8 +326,8 @@ error:
static PyMethodDef error_methods[] = { static PyMethodDef error_methods[] = {
/* Make Error and all its subclasses picklable. */ /* Make Error and all its subclasses picklable. */
{"__reduce__", (PyCFunction)psyco_error_reduce, METH_NOARGS }, {"__reduce__", (PyCFunction)error_reduce, METH_NOARGS },
{"__setstate__", (PyCFunction)psyco_error_setstate, METH_O }, {"__setstate__", (PyCFunction)error_setstate, METH_O },
{NULL} {NULL}
}; };

View File

@ -36,33 +36,33 @@
/* getquoted - return quoted representation for object */ /* getquoted - return quoted representation for object */
#define psyco_isqlquote_getquoted_doc \ #define isqlquote_getquoted_doc \
"getquoted() -- return SQL-quoted representation of this object" "getquoted() -- return SQL-quoted representation of this object"
static PyObject * static PyObject *
psyco_isqlquote_getquoted(isqlquoteObject *self, PyObject *args) isqlquote_getquoted(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
/* getbinary - return quoted representation for object */ /* getbinary - return quoted representation for object */
#define psyco_isqlquote_getbinary_doc \ #define isqlquote_getbinary_doc \
"getbinary() -- return SQL-quoted binary representation of this object" "getbinary() -- return SQL-quoted binary representation of this object"
static PyObject * static PyObject *
psyco_isqlquote_getbinary(isqlquoteObject *self, PyObject *args) isqlquote_getbinary(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
/* getbuffer - return quoted representation for object */ /* getbuffer - return quoted representation for object */
#define psyco_isqlquote_getbuffer_doc \ #define isqlquote_getbuffer_doc \
"getbuffer() -- return this object" "getbuffer() -- return this object"
static PyObject * static PyObject *
psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args) isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -75,14 +75,12 @@ psyco_isqlquote_getbuffer(isqlquoteObject *self, PyObject *args)
/* object method list */ /* object method list */
static struct PyMethodDef isqlquoteObject_methods[] = { static struct PyMethodDef isqlquoteObject_methods[] = {
{"getquoted", (PyCFunction)psyco_isqlquote_getquoted, {"getquoted", (PyCFunction)isqlquote_getquoted,
METH_NOARGS, psyco_isqlquote_getquoted_doc}, METH_NOARGS, isqlquote_getquoted_doc},
{"getbinary", (PyCFunction)psyco_isqlquote_getbinary, {"getbinary", (PyCFunction)isqlquote_getbinary,
METH_NOARGS, psyco_isqlquote_getbinary_doc}, METH_NOARGS, isqlquote_getbinary_doc},
{"getbuffer", (PyCFunction)psyco_isqlquote_getbuffer, {"getbuffer", (PyCFunction)isqlquote_getbuffer,
METH_NOARGS, psyco_isqlquote_getbuffer_doc}, METH_NOARGS, isqlquote_getbuffer_doc},
/* {"prepare", (PyCFunction)psyco_isqlquote_prepare,
METH_VARARGS, psyco_isqlquote_prepare_doc}, */
{NULL} {NULL}
}; };

View File

@ -657,7 +657,7 @@ pq_tpc_command_locked(
PyEval_RestoreThread(*tstate); PyEval_RestoreThread(*tstate);
/* convert the xid into the postgres transaction_id and quote it. */ /* convert the xid into the postgres transaction_id and quote it. */
if (!(etid = psycopg_escape_string(conn, tid, -1, NULL, NULL))) if (!(etid = psyco_escape_string(conn, tid, -1, NULL, NULL)))
{ goto exit; } { goto exit; }
/* prepare the command to the server */ /* prepare the command to the server */
@ -1298,7 +1298,7 @@ _pq_copy_in_v3(cursorObject *curs)
if (ex) { if (ex) {
PyObject *str; PyObject *str;
str = PyObject_Str(ex); str = PyObject_Str(ex);
str = psycopg_ensure_bytes(str); str = psyco_ensure_bytes(str);
if (str) { if (str) {
PyOS_snprintf(buf, sizeof(buf), PyOS_snprintf(buf, sizeof(buf),
"error in .read() call: %s %s", "error in .read() call: %s %s",
@ -1374,7 +1374,7 @@ _pq_copy_out_v3(cursorObject *curs)
} }
/* if the file is text we must pass it unicode. */ /* if the file is text we must pass it unicode. */
if (-1 == (is_text = psycopg_is_text_file(curs->copyfile))) { if (-1 == (is_text = psyco_is_text_file(curs->copyfile))) {
goto exit; goto exit;
} }

View File

@ -120,11 +120,11 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
} }
#define psyco_parse_dsn_doc \ #define parse_dsn_doc \
"parse_dsn(dsn) -> dict -- parse a connection string into parameters" "parse_dsn(dsn) -> dict -- parse a connection string into parameters"
static PyObject * static PyObject *
psyco_parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs) parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
char *err = NULL; char *err = NULL;
PQconninfoOption *options = NULL; PQconninfoOption *options = NULL;
@ -136,7 +136,7 @@ psyco_parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
} }
Py_INCREF(dsn); /* for ensure_bytes */ Py_INCREF(dsn); /* for ensure_bytes */
if (!(dsn = psycopg_ensure_bytes(dsn))) { goto exit; } if (!(dsn = psyco_ensure_bytes(dsn))) { goto exit; }
options = PQconninfoParse(Bytes_AS_STRING(dsn), &err); options = PQconninfoParse(Bytes_AS_STRING(dsn), &err);
if (options == NULL) { if (options == NULL) {
@ -149,7 +149,7 @@ psyco_parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit; goto exit;
} }
res = psycopg_dict_from_conninfo_options(options, /* include_password = */ 1); res = psyco_dict_from_conninfo_options(options, /* include_password = */ 1);
exit: exit:
PQconninfoFree(options); /* safe on null */ PQconninfoFree(options); /* safe on null */
@ -159,14 +159,14 @@ exit:
} }
#define psyco_quote_ident_doc \ #define quote_ident_doc \
"quote_ident(str, conn_or_curs) -> str -- wrapper around PQescapeIdentifier\n\n" \ "quote_ident(str, conn_or_curs) -> str -- wrapper around PQescapeIdentifier\n\n" \
":Parameters:\n" \ ":Parameters:\n" \
" * `str`: A bytes or unicode object\n" \ " * `str`: A bytes or unicode object\n" \
" * `conn_or_curs`: A connection or cursor, required" " * `conn_or_curs`: A connection or cursor, required"
static PyObject * static PyObject *
psyco_quote_ident(PyObject *self, PyObject *args, PyObject *kwargs) quote_ident(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *ident = NULL, *obj = NULL, *result = NULL; PyObject *ident = NULL, *obj = NULL, *result = NULL;
connectionObject *conn; connectionObject *conn;
@ -190,9 +190,9 @@ psyco_quote_ident(PyObject *self, PyObject *args, PyObject *kwargs)
} }
Py_INCREF(ident); /* for ensure_bytes */ Py_INCREF(ident); /* for ensure_bytes */
if (!(ident = psycopg_ensure_bytes(ident))) { goto exit; } if (!(ident = psyco_ensure_bytes(ident))) { goto exit; }
if (!(quoted = psycopg_escape_identifier(conn, if (!(quoted = psyco_escape_identifier(conn,
Bytes_AS_STRING(ident), Bytes_GET_SIZE(ident)))) { goto exit; } Bytes_AS_STRING(ident), Bytes_GET_SIZE(ident)))) { goto exit; }
result = conn_text_from_chars(conn, quoted); result = conn_text_from_chars(conn, quoted);
@ -205,7 +205,7 @@ exit:
} }
/** type registration **/ /** type registration **/
#define psyco_register_type_doc \ #define register_type_doc \
"register_type(obj, conn_or_curs) -> None -- register obj with psycopg type system\n\n" \ "register_type(obj, conn_or_curs) -> None -- register obj with psycopg type system\n\n" \
":Parameters:\n" \ ":Parameters:\n" \
" * `obj`: A type adapter created by `new_type()`\n" \ " * `obj`: A type adapter created by `new_type()`\n" \
@ -233,7 +233,7 @@ exit:
" * `baseobj`: Adapter to perform type conversion of a single array item." " * `baseobj`: Adapter to perform type conversion of a single array item."
static PyObject * static PyObject *
psyco_register_type(PyObject *self, PyObject *args) register_type(PyObject *self, PyObject *args)
{ {
PyObject *type, *obj = NULL; PyObject *type, *obj = NULL;
@ -271,7 +271,7 @@ psyco_register_type(PyObject *self, PyObject *args)
/* Make sure libcrypto thread callbacks are set up. */ /* Make sure libcrypto thread callbacks are set up. */
static void static void
psyco_libcrypto_threads_init(void) libcrypto_threads_init(void)
{ {
PyObject *m; PyObject *m;
@ -406,20 +406,20 @@ exit:
return rv; return rv;
} }
#define psyco_libpq_version_doc "Query actual libpq version loaded." #define libpq_version_doc "Query actual libpq version loaded."
static PyObject* static PyObject*
psyco_libpq_version(PyObject *self, PyObject *dummy) libpq_version(PyObject *self, PyObject *dummy)
{ {
return PyInt_FromLong(PQlibVersion()); return PyInt_FromLong(PQlibVersion());
} }
/* encrypt_password - Prepare the encrypted password form */ /* encrypt_password - Prepare the encrypted password form */
#define psyco_encrypt_password_doc \ #define encrypt_password_doc \
"encrypt_password(password, user, [scope], [algorithm]) -- Prepares the encrypted form of a PostgreSQL password.\n\n" "encrypt_password(password, user, [scope], [algorithm]) -- Prepares the encrypted form of a PostgreSQL password.\n\n"
static PyObject * static PyObject *
psyco_encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs) encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
char *encrypted = NULL; char *encrypted = NULL;
PyObject *password = NULL, *user = NULL; PyObject *password = NULL, *user = NULL;
@ -453,10 +453,10 @@ psyco_encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs)
} }
} }
if (!(user = psycopg_ensure_bytes(user))) { goto exit; } if (!(user = psyco_ensure_bytes(user))) { goto exit; }
if (!(password = psycopg_ensure_bytes(password))) { goto exit; } if (!(password = psyco_ensure_bytes(password))) { goto exit; }
if (algorithm != Py_None) { if (algorithm != Py_None) {
if (!(algorithm = psycopg_ensure_bytes(algorithm))) { if (!(algorithm = psyco_ensure_bytes(algorithm))) {
goto exit; goto exit;
} }
} }
@ -945,9 +945,9 @@ datetime_init(void)
/* Initialize the PyDateTimeAPI everywhere is used */ /* Initialize the PyDateTimeAPI everywhere is used */
PyDateTime_IMPORT; PyDateTime_IMPORT;
if (0 > psyco_adapter_datetime_init()) { return -1; } if (0 > adapter_datetime_init()) { return -1; }
if (0 > psyco_repl_curs_datetime_init()) { return -1; } if (0 > repl_curs_datetime_init()) { return -1; }
if (0 > psyco_replmsg_datetime_init()) { return -1; } if (0 > replmsg_datetime_init()) { return -1; }
Py_TYPE(&pydatetimeType) = &PyType_Type; Py_TYPE(&pydatetimeType) = &PyType_Type;
if (0 > PyType_Ready(&pydatetimeType)) { return -1; } if (0 > PyType_Ready(&pydatetimeType)) { return -1; }
@ -988,21 +988,21 @@ mxdatetime_init(PyObject *module)
static PyMethodDef psycopgMethods[] = { static PyMethodDef psycopgMethods[] = {
{"_connect", (PyCFunction)psyco_connect, {"_connect", (PyCFunction)psyco_connect,
METH_VARARGS|METH_KEYWORDS, psyco_connect_doc}, METH_VARARGS|METH_KEYWORDS, psyco_connect_doc},
{"parse_dsn", (PyCFunction)psyco_parse_dsn, {"parse_dsn", (PyCFunction)parse_dsn,
METH_VARARGS|METH_KEYWORDS, psyco_parse_dsn_doc}, METH_VARARGS|METH_KEYWORDS, parse_dsn_doc},
{"quote_ident", (PyCFunction)psyco_quote_ident, {"quote_ident", (PyCFunction)quote_ident,
METH_VARARGS|METH_KEYWORDS, psyco_quote_ident_doc}, METH_VARARGS|METH_KEYWORDS, quote_ident_doc},
{"adapt", (PyCFunction)psyco_microprotocols_adapt, {"adapt", (PyCFunction)psyco_microprotocols_adapt,
METH_VARARGS, psyco_microprotocols_adapt_doc}, METH_VARARGS, psyco_microprotocols_adapt_doc},
{"register_type", (PyCFunction)psyco_register_type, {"register_type", (PyCFunction)register_type,
METH_VARARGS, psyco_register_type_doc}, METH_VARARGS, register_type_doc},
{"new_type", (PyCFunction)typecast_from_python, {"new_type", (PyCFunction)typecast_from_python,
METH_VARARGS|METH_KEYWORDS, typecast_from_python_doc}, METH_VARARGS|METH_KEYWORDS, typecast_from_python_doc},
{"new_array_type", (PyCFunction)typecast_array_from_python, {"new_array_type", (PyCFunction)typecast_array_from_python,
METH_VARARGS|METH_KEYWORDS, typecast_array_from_python_doc}, METH_VARARGS|METH_KEYWORDS, typecast_array_from_python_doc},
{"libpq_version", (PyCFunction)psyco_libpq_version, {"libpq_version", (PyCFunction)libpq_version,
METH_NOARGS, psyco_libpq_version_doc}, METH_NOARGS, libpq_version_doc},
{"Date", (PyCFunction)psyco_Date, {"Date", (PyCFunction)psyco_Date,
METH_VARARGS, psyco_Date_doc}, METH_VARARGS, psyco_Date_doc},
@ -1042,8 +1042,8 @@ static PyMethodDef psycopgMethods[] = {
METH_O, psyco_set_wait_callback_doc}, METH_O, psyco_set_wait_callback_doc},
{"get_wait_callback", (PyCFunction)psyco_get_wait_callback, {"get_wait_callback", (PyCFunction)psyco_get_wait_callback,
METH_NOARGS, psyco_get_wait_callback_doc}, METH_NOARGS, psyco_get_wait_callback_doc},
{"encrypt_password", (PyCFunction)psyco_encrypt_password, {"encrypt_password", (PyCFunction)encrypt_password,
METH_VARARGS|METH_KEYWORDS, psyco_encrypt_password_doc}, METH_VARARGS|METH_KEYWORDS, encrypt_password_doc},
{NULL, NULL, 0, NULL} /* Sentinel */ {NULL, NULL, 0, NULL} /* Sentinel */
}; };
@ -1078,7 +1078,7 @@ INIT_MODULE(_psycopg)(void)
Dprintf("psycopgmodule: initializing psycopg %s", xstr(PSYCOPG_VERSION)); Dprintf("psycopgmodule: initializing psycopg %s", xstr(PSYCOPG_VERSION));
/* initialize libcrypto threading callbacks */ /* initialize libcrypto threading callbacks */
psyco_libcrypto_threads_init(); libcrypto_threads_init();
/* initialize types and objects not exposed to the module */ /* initialize types and objects not exposed to the module */
Py_TYPE(&typecastType) = &PyType_Type; Py_TYPE(&typecastType) = &PyType_Type;

View File

@ -97,7 +97,7 @@ replicationConnection_init(replicationConnectionObject *self,
goto exit; goto exit;
} }
if (!(newdsn = psycopg_make_dsn(dsn, dsnopts))) { goto exit; } if (!(newdsn = psyco_make_dsn(dsn, dsnopts))) { goto exit; }
if (!(newargs = PyTuple_Pack(2, newdsn, async))) { goto exit; } if (!(newargs = PyTuple_Pack(2, newdsn, async))) { goto exit; }
/* only attempt the connection once we've handled all possible errors */ /* only attempt the connection once we've handled all possible errors */

View File

@ -50,7 +50,7 @@ typedef struct replicationCursorObject {
} replicationCursorObject; } replicationCursorObject;
RAISES_NEG HIDDEN int psyco_repl_curs_datetime_init(void); RAISES_NEG HIDDEN int repl_curs_datetime_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -38,11 +38,11 @@
#include "datetime.h" #include "datetime.h"
#define psyco_repl_curs_start_replication_expert_doc \ #define start_replication_expert_doc \
"start_replication_expert(command, decode=False) -- Start replication with a given command." "start_replication_expert(command, decode=False) -- Start replication with a given command."
static PyObject * static PyObject *
psyco_repl_curs_start_replication_expert(replicationCursorObject *self, start_replication_expert(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -60,12 +60,11 @@ psyco_repl_curs_start_replication_expert(replicationCursorObject *self,
EXC_IF_GREEN(start_replication_expert); EXC_IF_GREEN(start_replication_expert);
EXC_IF_TPC_PREPARED(conn, start_replication_expert); EXC_IF_TPC_PREPARED(conn, start_replication_expert);
if (!(command = psyco_curs_validate_sql_basic( if (!(command = curs_validate_sql_basic((cursorObject *)self, command))) {
(cursorObject *)self, command))) {
goto exit; goto exit;
} }
Dprintf("psyco_repl_curs_start_replication_expert: '%s'; decode: %ld", Dprintf("start_replication_expert: '%s'; decode: %ld",
Bytes_AS_STRING(command), decode); Bytes_AS_STRING(command), decode);
if (pq_execute(curs, Bytes_AS_STRING(command), conn->async, if (pq_execute(curs, Bytes_AS_STRING(command), conn->async,
@ -82,11 +81,11 @@ exit:
return res; return res;
} }
#define psyco_repl_curs_consume_stream_doc \ #define consume_stream_doc \
"consume_stream(consumer, keepalive_interval=10) -- Consume replication stream." "consume_stream(consumer, keepalive_interval=10) -- Consume replication stream."
static PyObject * static PyObject *
psyco_repl_curs_consume_stream(replicationCursorObject *self, consume_stream(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -104,7 +103,7 @@ psyco_repl_curs_consume_stream(replicationCursorObject *self,
EXC_IF_GREEN(consume_stream); EXC_IF_GREEN(consume_stream);
EXC_IF_TPC_PREPARED(self->cur.conn, consume_stream); EXC_IF_TPC_PREPARED(self->cur.conn, consume_stream);
Dprintf("psyco_repl_curs_consume_stream"); Dprintf("consume_stream");
if (keepalive_interval < 1.0) { if (keepalive_interval < 1.0) {
psyco_set_error(ProgrammingError, curs, "keepalive_interval must be >= 1 (sec)"); psyco_set_error(ProgrammingError, curs, "keepalive_interval must be >= 1 (sec)");
@ -136,11 +135,11 @@ psyco_repl_curs_consume_stream(replicationCursorObject *self,
return res; return res;
} }
#define psyco_repl_curs_read_message_doc \ #define read_message_doc \
"read_message() -- Try reading a replication message from the server (non-blocking)." "read_message() -- Try reading a replication message from the server (non-blocking)."
static PyObject * static PyObject *
psyco_repl_curs_read_message(replicationCursorObject *self, PyObject *dummy) read_message(replicationCursorObject *self, PyObject *dummy)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
replicationMessageObject *msg = NULL; replicationMessageObject *msg = NULL;
@ -159,11 +158,11 @@ psyco_repl_curs_read_message(replicationCursorObject *self, PyObject *dummy)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
#define psyco_repl_curs_send_feedback_doc \ #define send_feedback_doc \
"send_feedback(write_lsn=0, flush_lsn=0, apply_lsn=0, reply=False) -- Try sending a replication feedback message to the server and optionally request a reply." "send_feedback(write_lsn=0, flush_lsn=0, apply_lsn=0, reply=False) -- Try sending a replication feedback message to the server and optionally request a reply."
static PyObject * static PyObject *
psyco_repl_curs_send_feedback(replicationCursorObject *self, send_feedback(replicationCursorObject *self,
PyObject *args, PyObject *kwargs) PyObject *args, PyObject *kwargs)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
@ -196,7 +195,7 @@ psyco_repl_curs_send_feedback(replicationCursorObject *self,
RAISES_NEG int RAISES_NEG int
psyco_repl_curs_datetime_init(void) repl_curs_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;
@ -207,11 +206,11 @@ psyco_repl_curs_datetime_init(void)
return 0; return 0;
} }
#define psyco_repl_curs_io_timestamp_doc \ #define repl_curs_io_timestamp_doc \
"io_timestamp -- the timestamp of latest IO with the server" "io_timestamp -- the timestamp of latest IO with the server"
static PyObject * static PyObject *
psyco_repl_curs_get_io_timestamp(replicationCursorObject *self) repl_curs_get_io_timestamp(replicationCursorObject *self)
{ {
cursorObject *curs = &self->cur; cursorObject *curs = &self->cur;
PyObject *tval, *res = NULL; PyObject *tval, *res = NULL;
@ -232,14 +231,14 @@ psyco_repl_curs_get_io_timestamp(replicationCursorObject *self)
/* object method list */ /* object method list */
static struct PyMethodDef replicationCursorObject_methods[] = { static struct PyMethodDef replicationCursorObject_methods[] = {
{"start_replication_expert", (PyCFunction)psyco_repl_curs_start_replication_expert, {"start_replication_expert", (PyCFunction)start_replication_expert,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_start_replication_expert_doc}, METH_VARARGS|METH_KEYWORDS, start_replication_expert_doc},
{"consume_stream", (PyCFunction)psyco_repl_curs_consume_stream, {"consume_stream", (PyCFunction)consume_stream,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_consume_stream_doc}, METH_VARARGS|METH_KEYWORDS, consume_stream_doc},
{"read_message", (PyCFunction)psyco_repl_curs_read_message, {"read_message", (PyCFunction)read_message,
METH_NOARGS, psyco_repl_curs_read_message_doc}, METH_NOARGS, read_message_doc},
{"send_feedback", (PyCFunction)psyco_repl_curs_send_feedback, {"send_feedback", (PyCFunction)send_feedback,
METH_VARARGS|METH_KEYWORDS, psyco_repl_curs_send_feedback_doc}, METH_VARARGS|METH_KEYWORDS, send_feedback_doc},
{NULL} {NULL}
}; };
@ -247,8 +246,8 @@ static struct PyMethodDef replicationCursorObject_methods[] = {
static struct PyGetSetDef replicationCursorObject_getsets[] = { static struct PyGetSetDef replicationCursorObject_getsets[] = {
{ "io_timestamp", { "io_timestamp",
(getter)psyco_repl_curs_get_io_timestamp, NULL, (getter)repl_curs_get_io_timestamp, NULL,
psyco_repl_curs_io_timestamp_doc, NULL }, repl_curs_io_timestamp_doc, NULL },
{NULL} {NULL}
}; };

View File

@ -48,7 +48,7 @@ struct replicationMessageObject {
int64_t send_time; int64_t send_time;
}; };
RAISES_NEG HIDDEN int psyco_replmsg_datetime_init(void); RAISES_NEG HIDDEN int replmsg_datetime_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -31,7 +31,7 @@
#include "datetime.h" #include "datetime.h"
RAISES_NEG int RAISES_NEG int
psyco_replmsg_datetime_init(void) replmsg_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;
@ -102,11 +102,11 @@ replmsg_dealloc(PyObject* obj)
Py_TYPE(obj)->tp_free(obj); Py_TYPE(obj)->tp_free(obj);
} }
#define psyco_replmsg_send_time_doc \ #define replmsg_send_time_doc \
"send_time - Timestamp of the replication message departure from the server." "send_time - Timestamp of the replication message departure from the server."
static PyObject * static PyObject *
psyco_replmsg_get_send_time(replicationMessageObject *self) replmsg_get_send_time(replicationMessageObject *self)
{ {
PyObject *tval, *res = NULL; PyObject *tval, *res = NULL;
double t; double t;
@ -142,8 +142,8 @@ static struct PyMemberDef replicationMessageObject_members[] = {
}; };
static struct PyGetSetDef replicationMessageObject_getsets[] = { static struct PyGetSetDef replicationMessageObject_getsets[] = {
{ "send_time", (getter)psyco_replmsg_get_send_time, NULL, { "send_time", (getter)replmsg_get_send_time, NULL,
psyco_replmsg_send_time_doc, NULL }, replmsg_send_time_doc, NULL },
{NULL} {NULL}
}; };

View File

@ -291,7 +291,7 @@ typecast_init(PyObject *module)
/* register the date/time typecasters with their original names */ /* register the date/time typecasters with their original names */
#ifdef HAVE_MXDATETIME #ifdef HAVE_MXDATETIME
if (0 == psyco_typecast_mxdatetime_init()) { if (0 == typecast_mxdatetime_init()) {
for (i = 0; typecast_mxdatetime[i].name != NULL; i++) { for (i = 0; typecast_mxdatetime[i].name != NULL; i++) {
t = (typecastObject *)typecast_from_c(&(typecast_mxdatetime[i]), dict); t = (typecastObject *)typecast_from_c(&(typecast_mxdatetime[i]), dict);
if (t == NULL) { goto exit; } if (t == NULL) { goto exit; }
@ -302,7 +302,7 @@ typecast_init(PyObject *module)
} }
#endif #endif
if (0 > psyco_typecast_datetime_init()) { goto exit; } if (0 > typecast_datetime_init()) { goto exit; }
for (i = 0; typecast_pydatetime[i].name != NULL; i++) { for (i = 0; typecast_pydatetime[i].name != NULL; i++) {
t = (typecastObject *)typecast_from_c(&(typecast_pydatetime[i]), dict); t = (typecastObject *)typecast_from_c(&(typecast_pydatetime[i]), dict);
if (t == NULL) { goto exit; } if (t == NULL) { goto exit; }
@ -435,7 +435,7 @@ typecast_repr(PyObject *self)
PyObject *rv; PyObject *rv;
Py_INCREF(name); Py_INCREF(name);
if (!(name = psycopg_ensure_bytes(name))) { if (!(name = psyco_ensure_bytes(name))) {
return NULL; return NULL;
} }

View File

@ -141,7 +141,7 @@ typecast_DECIMAL_cast(const char *s, Py_ssize_t len, PyObject *curs)
if ((buffer = PyMem_Malloc(len+1)) == NULL) if ((buffer = PyMem_Malloc(len+1)) == NULL)
return PyErr_NoMemory(); return PyErr_NoMemory();
strncpy(buffer, s, (size_t) len); buffer[len] = '\0'; strncpy(buffer, s, (size_t) len); buffer[len] = '\0';
decimalType = psyco_GetDecimalType(); decimalType = psyco_get_decimal_type();
/* Fall back on float if decimal is not available */ /* Fall back on float if decimal is not available */
if (decimalType != NULL) { if (decimalType != NULL) {
res = PyObject_CallFunction(decimalType, "s", buffer); res = PyObject_CallFunction(decimalType, "s", buffer);

View File

@ -132,9 +132,9 @@ PyTypeObject chunkType = {
}; };
static char *psycopg_parse_hex( static char *parse_hex(
const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout); const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout);
static char *psycopg_parse_escape( static char *parse_escape(
const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout); const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout);
/* The function is not static and not hidden as we use ctypes to test it. */ /* The function is not static and not hidden as we use ctypes to test it. */
@ -154,7 +154,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
* So the only robust option is to parse it ourselves - luckily it's * So the only robust option is to parse it ourselves - luckily it's
* an easy format. * an easy format.
*/ */
if (NULL == (buffer = psycopg_parse_hex(s, l, &len))) { if (NULL == (buffer = parse_hex(s, l, &len))) {
goto exit; goto exit;
} }
} }
@ -169,7 +169,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
* So we'll just have our better integrated parser, let's finish this * So we'll just have our better integrated parser, let's finish this
* story. * story.
*/ */
if (NULL == (buffer = psycopg_parse_escape(s, l, &len))) { if (NULL == (buffer = parse_escape(s, l, &len))) {
goto exit; goto exit;
} }
} }
@ -219,7 +219,7 @@ static const char hex_lut[128] = {
* In case of error set an exception and return NULL. * In case of error set an exception and return NULL.
*/ */
static char * static char *
psycopg_parse_hex(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout) parse_hex(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout)
{ {
char *ret = NULL; char *ret = NULL;
const char *bufend = bufin + sizein; const char *bufend = bufin + sizein;
@ -269,7 +269,7 @@ exit:
* In case of error set an exception and return NULL. * In case of error set an exception and return NULL.
*/ */
static char * static char *
psycopg_parse_escape(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout) parse_escape(const char *bufin, Py_ssize_t sizein, Py_ssize_t *sizeout)
{ {
char *ret = NULL; char *ret = NULL;
const char *bufend = bufin + sizein; const char *bufend = bufin + sizein;

View File

@ -27,7 +27,7 @@
#include "datetime.h" #include "datetime.h"
RAISES_NEG static int RAISES_NEG static int
psyco_typecast_datetime_init(void) typecast_datetime_init(void)
{ {
PyDateTime_IMPORT; PyDateTime_IMPORT;

View File

@ -29,10 +29,10 @@
/* Return 0 on success, -1 on failure, but don't set an exception */ /* Return 0 on success, -1 on failure, but don't set an exception */
static int static int
psyco_typecast_mxdatetime_init(void) typecast_mxdatetime_init(void)
{ {
if (mxDateTime_ImportModuleAndAPI()) { if (mxDateTime_ImportModuleAndAPI()) {
Dprintf("psyco_typecast_mxdatetime_init: mx.DateTime initialization failed"); Dprintf("typecast_mxdatetime_init: mx.DateTime initialization failed");
PyErr_Clear(); PyErr_Clear();
return -1; return -1;
} }

View File

@ -48,7 +48,7 @@
* including quotes. * including quotes.
*/ */
char * char *
psycopg_escape_string(connectionObject *conn, const char *from, Py_ssize_t len, psyco_escape_string(connectionObject *conn, const char *from, Py_ssize_t len,
char *to, Py_ssize_t *tolen) char *to, Py_ssize_t *tolen)
{ {
Py_ssize_t ql; Py_ssize_t ql;
@ -102,7 +102,7 @@ psycopg_escape_string(connectionObject *conn, const char *from, Py_ssize_t len,
* In case of error set a Python exception. * In case of error set a Python exception.
*/ */
char * char *
psycopg_escape_identifier(connectionObject *conn, const char *str, Py_ssize_t len) psyco_escape_identifier(connectionObject *conn, const char *str, Py_ssize_t len)
{ {
char *rv = NULL; char *rv = NULL;
@ -139,7 +139,7 @@ exit:
* If from is null, store null into to. * If from is null, store null into to.
*/ */
RAISES_NEG int RAISES_NEG int
psycopg_strdup(char **to, const char *from, Py_ssize_t len) psyco_strdup(char **to, const char *from, Py_ssize_t len)
{ {
if (!from) { if (!from) {
*to = NULL; *to = NULL;
@ -165,7 +165,7 @@ psycopg_strdup(char **to, const char *from, Py_ssize_t len)
* It is safe to call the function on NULL. * It is safe to call the function on NULL.
*/ */
STEALS(1) PyObject * STEALS(1) PyObject *
psycopg_ensure_bytes(PyObject *obj) psyco_ensure_bytes(PyObject *obj)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
if (!obj) { return NULL; } if (!obj) { return NULL; }
@ -195,7 +195,7 @@ psycopg_ensure_bytes(PyObject *obj)
* return value. It is safe to call it on NULL. * return value. It is safe to call it on NULL.
*/ */
STEALS(1) PyObject * STEALS(1) PyObject *
psycopg_ensure_text(PyObject *obj) psyco_ensure_text(PyObject *obj)
{ {
#if PY_2 #if PY_2
return obj; return obj;
@ -217,7 +217,7 @@ psycopg_ensure_text(PyObject *obj)
* Return 1 if it does, else 0, -1 on errors. * Return 1 if it does, else 0, -1 on errors.
*/ */
int int
psycopg_is_text_file(PyObject *f) psyco_is_text_file(PyObject *f)
{ {
/* NULL before any call. /* NULL before any call.
* then io.TextIOBase if exists, else None. */ * then io.TextIOBase if exists, else None. */
@ -226,16 +226,16 @@ psycopg_is_text_file(PyObject *f)
/* Try to import os.TextIOBase */ /* Try to import os.TextIOBase */
if (NULL == base) { if (NULL == base) {
PyObject *m; PyObject *m;
Dprintf("psycopg_is_text_file: importing io.TextIOBase"); Dprintf("psyco_is_text_file: importing io.TextIOBase");
if (!(m = PyImport_ImportModule("io"))) { if (!(m = PyImport_ImportModule("io"))) {
Dprintf("psycopg_is_text_file: io module not found"); Dprintf("psyco_is_text_file: io module not found");
PyErr_Clear(); PyErr_Clear();
Py_INCREF(Py_None); Py_INCREF(Py_None);
base = Py_None; base = Py_None;
} }
else { else {
if (!(base = PyObject_GetAttrString(m, "TextIOBase"))) { if (!(base = PyObject_GetAttrString(m, "TextIOBase"))) {
Dprintf("psycopg_is_text_file: io.TextIOBase not found"); Dprintf("psyco_is_text_file: io.TextIOBase not found");
PyErr_Clear(); PyErr_Clear();
Py_INCREF(Py_None); Py_INCREF(Py_None);
base = Py_None; base = Py_None;
@ -253,7 +253,7 @@ psycopg_is_text_file(PyObject *f)
/* Make a dict out of PQconninfoOption array */ /* Make a dict out of PQconninfoOption array */
PyObject * PyObject *
psycopg_dict_from_conninfo_options(PQconninfoOption *options, int include_password) psyco_dict_from_conninfo_options(PQconninfoOption *options, int include_password)
{ {
PyObject *dict, *res = NULL; PyObject *dict, *res = NULL;
PQconninfoOption *o; PQconninfoOption *o;
@ -287,7 +287,7 @@ exit:
* Helper to call psycopg2.extensions.make_dsn() * Helper to call psycopg2.extensions.make_dsn()
*/ */
PyObject * PyObject *
psycopg_make_dsn(PyObject *dsn, PyObject *kwargs) psyco_make_dsn(PyObject *dsn, PyObject *kwargs)
{ {
PyObject *ext = NULL, *make_dsn = NULL; PyObject *ext = NULL, *make_dsn = NULL;
PyObject *args = NULL, *rv = NULL; PyObject *args = NULL, *rv = NULL;
@ -314,7 +314,7 @@ exit:
* len is optional: use -1 to have it calculated by the function. * len is optional: use -1 to have it calculated by the function.
*/ */
PyObject * PyObject *
psycopg_text_from_chars_safe(const char *str, Py_ssize_t len, PyObject *decoder) psyco_text_from_chars_safe(const char *str, Py_ssize_t len, PyObject *decoder)
{ {
#if PY_2 #if PY_2
@ -430,7 +430,7 @@ psyco_is_main_interp(void)
#endif #endif
} }
/* psyco_GetDecimalType /* psyco_get_decimal_type
Return a new reference to the decimal type. Return a new reference to the decimal type.
@ -439,7 +439,7 @@ psyco_is_main_interp(void)
*/ */
PyObject * PyObject *
psyco_GetDecimalType(void) psyco_get_decimal_type(void)
{ {
static PyObject *cachedType = NULL; static PyObject *cachedType = NULL;
PyObject *decimalType = NULL; PyObject *decimalType = NULL;

View File

@ -31,32 +31,32 @@ typedef struct cursorObject cursorObject;
typedef struct connectionObject connectionObject; typedef struct connectionObject connectionObject;
typedef struct replicationMessageObject replicationMessageObject; typedef struct replicationMessageObject replicationMessageObject;
HIDDEN char *psycopg_escape_string( HIDDEN char *psyco_escape_string(
connectionObject *conn, connectionObject *conn,
const char *from, Py_ssize_t len, char *to, Py_ssize_t *tolen); const char *from, Py_ssize_t len, char *to, Py_ssize_t *tolen);
HIDDEN char *psycopg_escape_identifier( HIDDEN char *psyco_escape_identifier(
connectionObject *conn, const char *str, Py_ssize_t len); connectionObject *conn, const char *str, Py_ssize_t len);
HIDDEN int psycopg_strdup(char **to, const char *from, Py_ssize_t len); HIDDEN int psyco_strdup(char **to, const char *from, Py_ssize_t len);
STEALS(1) HIDDEN PyObject * psycopg_ensure_bytes(PyObject *obj); STEALS(1) HIDDEN PyObject * psyco_ensure_bytes(PyObject *obj);
STEALS(1) HIDDEN PyObject * psycopg_ensure_text(PyObject *obj); STEALS(1) HIDDEN PyObject * psyco_ensure_text(PyObject *obj);
HIDDEN int psycopg_is_text_file(PyObject *f); HIDDEN int psyco_is_text_file(PyObject *f);
HIDDEN PyObject *psycopg_dict_from_conninfo_options( HIDDEN PyObject *psyco_dict_from_conninfo_options(
PQconninfoOption *options, int include_password); PQconninfoOption *options, int include_password);
HIDDEN PyObject *psycopg_make_dsn(PyObject *dsn, PyObject *kwargs); HIDDEN PyObject *psyco_make_dsn(PyObject *dsn, PyObject *kwargs);
HIDDEN PyObject *psycopg_text_from_chars_safe( HIDDEN PyObject *psyco_text_from_chars_safe(
const char *str, Py_ssize_t len, PyObject *decoder); const char *str, Py_ssize_t len, PyObject *decoder);
HIDDEN RAISES BORROWED PyObject *psyco_set_error( HIDDEN RAISES BORROWED PyObject *psyco_set_error(
PyObject *exc, cursorObject *curs, const char *msg); PyObject *exc, cursorObject *curs, const char *msg);
HIDDEN PyObject *psyco_GetDecimalType(void); HIDDEN PyObject *psyco_get_decimal_type(void);
HIDDEN PyObject *Bytes_Format(PyObject *format, PyObject *args); HIDDEN PyObject *Bytes_Format(PyObject *format, PyObject *args);

View File

@ -343,8 +343,8 @@ _xid_base64_enc_dec(const char *funcname, PyObject *s)
if (!(func = PyObject_GetAttrString(base64, funcname))) { goto exit; } if (!(func = PyObject_GetAttrString(base64, funcname))) { goto exit; }
Py_INCREF(s); Py_INCREF(s);
if (!(s = psycopg_ensure_bytes(s))) { goto exit; } if (!(s = psyco_ensure_bytes(s))) { goto exit; }
rv = psycopg_ensure_text(PyObject_CallFunctionObjArgs(func, s, NULL)); rv = psyco_ensure_text(PyObject_CallFunctionObjArgs(func, s, NULL));
Py_DECREF(s); Py_DECREF(s);
exit: exit: