Query mogrification in bytes.

This commit is contained in:
Daniele Varrazzo 2010-12-23 04:06:34 +01:00
parent c3196ebd9d
commit 87a7ebac10

View File

@ -314,7 +314,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
the curren exception (we will later restore it if the type or the the curren exception (we will later restore it if the type or the
strings do not match.) */ strings do not match.) */
if (!(fquery = Text_Format(query, args))) { if (!(fquery = Bytes_Format(query, args))) {
PyObject *err, *arg, *trace; PyObject *err, *arg, *trace;
int pe = 0; int pe = 0;
@ -397,15 +397,9 @@ _psyco_curs_execute(cursorObject *self,
} }
if (self->name != NULL) { if (self->name != NULL) {
#if PY_MAJOR_VERSION < 3 self->query = Bytes_FromFormat(
self->query = PyString_FromFormat(
"DECLARE %s CURSOR WITHOUT HOLD FOR %s", "DECLARE %s CURSOR WITHOUT HOLD FOR %s",
self->name, PyString_AS_STRING(fquery)); self->name, Bytes_AS_STRING(fquery));
#else
self->query = PyUnicode_FromFormat(
"DECLARE %s CURSOR WITHOUT HOLD FOR %U",
self->name, fquery);
#endif
Py_DECREF(fquery); Py_DECREF(fquery);
} }
else { else {
@ -414,15 +408,9 @@ _psyco_curs_execute(cursorObject *self,
} }
else { else {
if (self->name != NULL) { if (self->name != NULL) {
#if PY_MAJOR_VERSION < 3 self->query = Bytes_FromFormat(
self->query = PyString_FromFormat(
"DECLARE %s CURSOR WITHOUT HOLD FOR %s", "DECLARE %s CURSOR WITHOUT HOLD FOR %s",
self->name, PyString_AS_STRING(operation)); self->name, Bytes_AS_STRING(operation));
#else
self->query = PyUnicode_FromFormat(
"DECLARE %s CURSOR WITHOUT HOLD FOR %U",
self->name, operation);
#endif
} }
else { else {
/* Transfer reference ownership of the str in operation to /* Transfer reference ownership of the str in operation to