def test_error_in_conform(self):
val = DeclTypesTests.BadConform(TypeError)
- with self.assertRaises(sqlite.InterfaceError):
+ with self.assertRaises(sqlite.ProgrammingError):
self.cur.execute("insert into test(bad) values (?)", (val,))
- with self.assertRaises(sqlite.InterfaceError):
+ with self.assertRaises(sqlite.ProgrammingError):
self.cur.execute("insert into test(bad) values (:val)", {"val": val})
val = DeclTypesTests.BadConform(KeyboardInterrupt)
def test_unsupported_seq(self):
class Bar: pass
val = Bar()
- with self.assertRaises(sqlite.InterfaceError):
+ with self.assertRaises(sqlite.ProgrammingError):
self.cur.execute("insert into test(f) values (?)", (val,))
def test_unsupported_dict(self):
class Bar: pass
val = Bar()
- with self.assertRaises(sqlite.InterfaceError):
+ with self.assertRaises(sqlite.ProgrammingError):
self.cur.execute("insert into test(f) values (:val)", {"val": val})
def test_blob(self):
}
static int
-bind_param(pysqlite_Statement *self, int pos, PyObject *parameter)
+bind_param(pysqlite_state *state, pysqlite_Statement *self, int pos,
+ PyObject *parameter)
{
int rc = SQLITE_OK;
const char *string;
break;
}
case TYPE_UNKNOWN:
+ PyErr_Format(state->ProgrammingError,
+ "Error binding parameter %d: type '%s' is not supported",
+ pos, Py_TYPE(parameter)->tp_name);
rc = -1;
}
}
}
- rc = bind_param(self, i + 1, adapted);
+ rc = bind_param(state, self, i + 1, adapted);
Py_DECREF(adapted);
if (rc != SQLITE_OK) {
- if (!PyErr_Occurred()) {
- PyErr_Format(state->InterfaceError,
- "Error binding parameter %d - "
- "probably unsupported type.", i);
- }
+ PyObject *exc, *val, *tb;
+ PyErr_Fetch(&exc, &val, &tb);
+ sqlite3 *db = sqlite3_db_handle(self->st);
+ _pysqlite_seterror(state, db);
+ _PyErr_ChainExceptions(exc, val, tb);
return;
}
}
}
}
- rc = bind_param(self, i, adapted);
+ rc = bind_param(state, self, i, adapted);
Py_DECREF(adapted);
if (rc != SQLITE_OK) {
- if (!PyErr_Occurred()) {
- PyErr_Format(state->InterfaceError,
- "Error binding parameter :%s - "
- "probably unsupported type.", binding_name);
- }
+ PyObject *exc, *val, *tb;
+ PyErr_Fetch(&exc, &val, &tb);
+ sqlite3 *db = sqlite3_db_handle(self->st);
+ _pysqlite_seterror(state, db);
+ _PyErr_ChainExceptions(exc, val, tb);
return;
}
}
} else {
- PyErr_SetString(PyExc_ValueError, "parameters are of unsupported type");
+ PyErr_SetString(state->ProgrammingError,
+ "parameters are of unsupported type");
}
}