summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2008-09-22 06:04:51 (GMT)
committerGerhard Häring <gh@ghaering.de>2008-09-22 06:04:51 (GMT)
commit6117f423c4754a4626c99eb3998db7282b1aa36b (patch)
tree89c5234711a5c8bd6c239f8189ffe4cefa0948c3 /Modules/_sqlite/statement.c
parentd0db98fcd869605f28dc600bfeba032565e31855 (diff)
downloadcpython-6117f423c4754a4626c99eb3998db7282b1aa36b.zip
cpython-6117f423c4754a4626c99eb3998db7282b1aa36b.tar.gz
cpython-6117f423c4754a4626c99eb3998db7282b1aa36b.tar.bz2
Issue #3659: Values of string subclasses were not handled correctly when used
as bind parameters. Reviewed by Bejnamin Peterson.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index af6d5cb..f1c0e7c 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -43,7 +43,6 @@ typedef enum {
typedef enum {
TYPE_LONG,
TYPE_FLOAT,
- TYPE_STRING,
TYPE_UNICODE,
TYPE_BUFFER,
TYPE_UNKNOWN
@@ -96,7 +95,6 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
char* string;
Py_ssize_t buflen;
parameter_type paramtype;
- char* c;
if (parameter == Py_None) {
rc = sqlite3_bind_null(self->st, pos);
@@ -114,24 +112,13 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
} else if (PyFloat_Check(parameter)) {
paramtype = TYPE_FLOAT;
} else if (PyUnicode_Check(parameter)) {
- paramtype = TYPE_STRING;
+ paramtype = TYPE_UNICODE;
} else if (PyObject_CheckBuffer(parameter)) {
paramtype = TYPE_BUFFER;
} else {
paramtype = TYPE_UNKNOWN;
}
- if (paramtype == TYPE_STRING && !allow_8bit_chars) {
- string = PyBytes_AS_STRING(parameter);
- for (c = string; *c != 0; c++) {
- if (*c & 0x80) {
- PyErr_SetString(pysqlite_ProgrammingError, "You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.");
- rc = -1;
- goto final;
- }
- }
- }
-
switch (paramtype) {
case TYPE_LONG:
/* in the overflow error case, longval/longlongval is -1, and an exception is set */