Prefix 'psycopg_' changed to 'psyco_'

This commit is contained in:
Daniele Varrazzo 2019-03-17 18:45:25 +00:00
parent e4d365705a
commit dc5dd30526
22 changed files with 76 additions and 76 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,7 +73,7 @@ qstring_quote(qstringObject *self)
/* encode the string into buffer */
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;
}
@ -107,7 +107,7 @@ qstring_getquoted(qstringObject *self, PyObject *args)
static PyObject *
qstring_str(qstringObject *self)
{
return psycopg_ensure_text(qstring_getquoted(self, NULL));
return psyco_ensure_text(qstring_getquoted(self, NULL));
}
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) */
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 (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);
PyMem_Free((void *)self->encoding);

View File

@ -79,7 +79,7 @@ const int SRV_STATE_UNCHANGED = -1;
PyObject *
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 */
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 */
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);
/* 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; }
Py_BEGIN_ALLOW_THREADS;

View File

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

View File

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

View File

@ -86,7 +86,7 @@ curs_close(cursorObject *self, PyObject *dummy)
* closing it (the view exists since PG 8.2 according to docs).
*/
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))) {
goto exit;
}
@ -1059,10 +1059,10 @@ curs_callproc(cursorObject *self, PyObject *args)
Py_INCREF(pname); /* was borrowed */
/* 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 (!(scpnames[i] = psycopg_escape_identifier(
if (!(scpnames[i] = psyco_escape_identifier(
self->conn, cpname, -1))) {
Py_CLEAR(pname);
goto exit;
@ -1332,7 +1332,7 @@ static char *_psyco_curs_copy_columns(PyObject *columns)
columnlist[0] = '(';
while ((col = PyIter_Next(coliter)) != NULL) {
if (!(col = psycopg_ensure_bytes(col))) {
if (!(col = psyco_ensure_bytes(col))) {
Py_DECREF(coliter);
goto error;
}
@ -1423,12 +1423,12 @@ curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
if (NULL == (columnlist = _psyco_curs_copy_columns(columns)))
goto exit;
if (!(quoted_delimiter = psycopg_escape_string(
if (!(quoted_delimiter = psyco_escape_string(
self->conn, sep, -1, NULL, NULL))) {
goto exit;
}
if (!(quoted_null = psycopg_escape_string(
if (!(quoted_null = psyco_escape_string(
self->conn, null, -1, NULL, NULL))) {
goto exit;
}
@ -1515,12 +1515,12 @@ curs_copy_to(cursorObject *self, PyObject *args, PyObject *kwargs)
if (NULL == (columnlist = _psyco_curs_copy_columns(columns)))
goto exit;
if (!(quoted_delimiter = psycopg_escape_string(
if (!(quoted_delimiter = psyco_escape_string(
self->conn, sep, -1, NULL, NULL))) {
goto exit;
}
if (!(quoted_null = psycopg_escape_string(
if (!(quoted_null = psyco_escape_string(
self->conn, null, -1, NULL, NULL))) {
goto exit;
}
@ -1874,10 +1874,10 @@ cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
Dprintf("cursor_setup: parameters: name = %s, conn = %p", name, conn);
if (name) {
if (0 > psycopg_strdup(&self->name, name, -1)) {
if (0 > psyco_strdup(&self->name, name, -1)) {
return -1;
}
if (!(self->qname = psycopg_escape_identifier(conn, name, -1))) {
if (!(self->qname = psyco_escape_identifier(conn, name, -1))) {
return -1;
}
}
@ -1982,7 +1982,7 @@ cursor_init(PyObject *obj, PyObject *args, PyObject *kwargs)
if (name != Py_None) {
Py_INCREF(name); /* for ensure_bytes */
if (!(bname = psycopg_ensure_bytes(name))) {
if (!(bname = psyco_ensure_bytes(name))) {
/* name has had a ref stolen */
goto exit;
}

View File

@ -34,7 +34,7 @@
PyObject *
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);
}

View File

@ -657,7 +657,7 @@ pq_tpc_command_locked(
PyEval_RestoreThread(*tstate);
/* 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; }
/* prepare the command to the server */
@ -1298,7 +1298,7 @@ _pq_copy_in_v3(cursorObject *curs)
if (ex) {
PyObject *str;
str = PyObject_Str(ex);
str = psycopg_ensure_bytes(str);
str = psyco_ensure_bytes(str);
if (str) {
PyOS_snprintf(buf, sizeof(buf),
"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 (-1 == (is_text = psycopg_is_text_file(curs->copyfile))) {
if (-1 == (is_text = psyco_is_text_file(curs->copyfile))) {
goto exit;
}

View File

@ -136,7 +136,7 @@ parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
}
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);
if (options == NULL) {
@ -149,7 +149,7 @@ parse_dsn(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
res = psycopg_dict_from_conninfo_options(options, /* include_password = */ 1);
res = psyco_dict_from_conninfo_options(options, /* include_password = */ 1);
exit:
PQconninfoFree(options); /* safe on null */
@ -190,9 +190,9 @@ quote_ident(PyObject *self, PyObject *args, PyObject *kwargs)
}
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; }
result = conn_text_from_chars(conn, quoted);
@ -453,10 +453,10 @@ encrypt_password(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (!(user = psycopg_ensure_bytes(user))) { goto exit; }
if (!(password = psycopg_ensure_bytes(password))) { goto exit; }
if (!(user = psyco_ensure_bytes(user))) { goto exit; }
if (!(password = psyco_ensure_bytes(password))) { goto exit; }
if (algorithm != Py_None) {
if (!(algorithm = psycopg_ensure_bytes(algorithm))) {
if (!(algorithm = psyco_ensure_bytes(algorithm))) {
goto exit;
}
}

View File

@ -97,7 +97,7 @@ replicationConnection_init(replicationConnectionObject *self,
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; }
/* only attempt the connection once we've handled all possible errors */

View File

@ -435,7 +435,7 @@ typecast_repr(PyObject *self)
PyObject *rv;
Py_INCREF(name);
if (!(name = psycopg_ensure_bytes(name))) {
if (!(name = psyco_ensure_bytes(name))) {
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)
return PyErr_NoMemory();
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 */
if (decimalType != NULL) {
res = PyObject_CallFunction(decimalType, "s", buffer);

View File

@ -48,7 +48,7 @@
* including quotes.
*/
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)
{
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.
*/
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;
@ -139,7 +139,7 @@ exit:
* If from is null, store null into to.
*/
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) {
*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.
*/
STEALS(1) PyObject *
psycopg_ensure_bytes(PyObject *obj)
psyco_ensure_bytes(PyObject *obj)
{
PyObject *rv = NULL;
if (!obj) { return NULL; }
@ -195,7 +195,7 @@ psycopg_ensure_bytes(PyObject *obj)
* return value. It is safe to call it on NULL.
*/
STEALS(1) PyObject *
psycopg_ensure_text(PyObject *obj)
psyco_ensure_text(PyObject *obj)
{
#if PY_2
return obj;
@ -217,7 +217,7 @@ psycopg_ensure_text(PyObject *obj)
* Return 1 if it does, else 0, -1 on errors.
*/
int
psycopg_is_text_file(PyObject *f)
psyco_is_text_file(PyObject *f)
{
/* NULL before any call.
* then io.TextIOBase if exists, else None. */
@ -226,16 +226,16 @@ psycopg_is_text_file(PyObject *f)
/* Try to import os.TextIOBase */
if (NULL == base) {
PyObject *m;
Dprintf("psycopg_is_text_file: importing io.TextIOBase");
Dprintf("psyco_is_text_file: importing io.TextIOBase");
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();
Py_INCREF(Py_None);
base = Py_None;
}
else {
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();
Py_INCREF(Py_None);
base = Py_None;
@ -253,7 +253,7 @@ psycopg_is_text_file(PyObject *f)
/* Make a dict out of PQconninfoOption array */
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;
PQconninfoOption *o;
@ -287,7 +287,7 @@ exit:
* Helper to call psycopg2.extensions.make_dsn()
*/
PyObject *
psycopg_make_dsn(PyObject *dsn, PyObject *kwargs)
psyco_make_dsn(PyObject *dsn, PyObject *kwargs)
{
PyObject *ext = NULL, *make_dsn = NULL;
PyObject *args = NULL, *rv = NULL;
@ -314,7 +314,7 @@ exit:
* len is optional: use -1 to have it calculated by the function.
*/
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
@ -430,7 +430,7 @@ psyco_is_main_interp(void)
#endif
}
/* psyco_GetDecimalType
/* psyco_get_decimal_type
Return a new reference to the decimal type.
@ -439,7 +439,7 @@ psyco_is_main_interp(void)
*/
PyObject *
psyco_GetDecimalType(void)
psyco_get_decimal_type(void)
{
static PyObject *cachedType = NULL;
PyObject *decimalType = NULL;

View File

@ -31,32 +31,32 @@ typedef struct cursorObject cursorObject;
typedef struct connectionObject connectionObject;
typedef struct replicationMessageObject replicationMessageObject;
HIDDEN char *psycopg_escape_string(
HIDDEN char *psyco_escape_string(
connectionObject *conn,
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);
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 * psycopg_ensure_text(PyObject *obj);
STEALS(1) HIDDEN PyObject * psyco_ensure_bytes(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);
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);
HIDDEN RAISES BORROWED PyObject *psyco_set_error(
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);

View File

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