From 35f5d46fa0d5f2e554fceba9a8e6ebe5798c9d9b Mon Sep 17 00:00:00 2001 From: Gerhard Haering Date: Thu, 5 Aug 2010 16:26:16 +0200 Subject: [PATCH] Trying to execute more than one statement with execute() or throwing anything other than string or unicode as the first parameter to execute() now raises a ProgrammingError instead of a Warning. This makes much more sense. --- lib/test/dbapi.py | 4 ++-- src/connection.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/test/dbapi.py b/lib/test/dbapi.py index 352ff2e..ea0b417 100644 --- a/lib/test/dbapi.py +++ b/lib/test/dbapi.py @@ -164,8 +164,8 @@ def CheckExecuteIllegalSql(self): def CheckExecuteTooMuchSql(self): try: self.cu.execute("select 5+4; select 4+5") - self.fail("should have raised a Warning") - except sqlite.Warning: + self.fail("should have raised a ProgrammingError") + except sqlite.ProgrammingError: return except: self.fail("raised wrong exception") diff --git a/src/connection.c b/src/connection.c index d1060de..8861462 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1201,9 +1201,9 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py if (rc != SQLITE_OK) { if (rc == PYSQLITE_TOO_MUCH_SQL) { - PyErr_SetString(pysqlite_Warning, "You can only execute one statement at a time."); + PyErr_SetString(pysqlite_ProgrammingError, "You can only execute one statement at a time."); } else if (rc == PYSQLITE_SQL_WRONG_TYPE) { - PyErr_SetString(pysqlite_Warning, "SQL is of wrong type. Must be string or unicode."); + PyErr_SetString(pysqlite_ProgrammingError, "SQL is of wrong type. Must be string or unicode."); } else { (void)pysqlite_statement_reset(statement); _pysqlite_seterror(self->db, NULL);