mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-12-01 21:23:43 +03:00
Prefix 'psycopg_' changed to 'psyco_'
This commit is contained in:
parent
e4d365705a
commit
dc5dd30526
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -86,7 +86,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -1059,10 +1059,10 @@ 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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -1423,12 +1423,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -1515,12 +1515,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ 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 @@ 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 */
|
||||||
|
@ -190,9 +190,9 @@ 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);
|
||||||
|
@ -453,10 +453,10 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user