diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 2e61acf8cb9..da445519d96 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -176,6 +176,13 @@ class RegressionTests(unittest.TestCase): class MyStr(str): pass self.con.execute("select ?", (MyStr("abc"),)) + 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") return unittest.TestSuite((regression_suite,)) diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 08588bcdeee..4b8088d0f5e 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -979,6 +979,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) {