diff options
-rw-r--r-- | Lib/sqlite3/test/regression.py | 19 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 6 |
2 files changed, 18 insertions, 7 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 7ed0d92..255bd3f 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -242,8 +242,7 @@ class RegressionTests(unittest.TestCase): Verifies that running a PRAGMA statement that does an autocommit does work. This did not work in 2.5.3/2.5.4. """ - con = sqlite.connect(":memory:") - cur = con.cursor() + cur = self.con.cursor() cur.execute("create table foo(bar)") cur.execute("insert into foo(bar) values (5)") @@ -263,11 +262,17 @@ class RegressionTests(unittest.TestCase): def __hash__(self): raise TypeError() var = NotHashable() - con = sqlite.connect(":memory:") - self.assertRaises(TypeError, con.create_function, var) - self.assertRaises(TypeError, con.create_aggregate, var) - self.assertRaises(TypeError, con.set_authorizer, var) - self.assertRaises(TypeError, con.set_progress_handler, var) + self.assertRaises(TypeError, self.con.create_function, var) + self.assertRaises(TypeError, self.con.create_aggregate, var) + self.assertRaises(TypeError, self.con.set_authorizer, var) + self.assertRaises(TypeError, self.con.set_progress_handler, var) + + def CheckConnectionCall(self): + """ + Call a connection with a non-string SQL request: check error handling + of the statement constructor. + """ + self.assertRaises(sqlite.Warning, self.con, 1) def suite(): regression_suite = unittest.makeSuite(RegressionTests, "Check") diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 2ce27f5..d916c34 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1125,6 +1125,12 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py return NULL; } + statement->db = NULL; + statement->st = NULL; + statement->sql = NULL; + statement->in_use = 0; + statement->in_weakreflist = NULL; + rc = pysqlite_statement_create(statement, self, sql); if (rc != SQLITE_OK) { |