]> granicus.if.org Git - python/commitdiff
Merged revisions 78898 via svnmerge from
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 21 Mar 2010 13:52:56 +0000 (13:52 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 21 Mar 2010 13:52:56 +0000 (13:52 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78898 | victor.stinner | 2010-03-13 04:27:07 +0100 (sam., 13 mars 2010) | 7 lines

  sqlite3: Fix a segfault on calling a connection with something else than a
  string. Initialize all attributes to be able to call the statement destructor
  on error.

  Avoid also a duplicate connection in some tests: setUp() does already open a
  connection (":memory:").
........

Lib/sqlite3/test/regression.py
Modules/_sqlite/connection.c

index d07c237fd4c39071ccdedb28e492977234279b9e..2a519dcea2a9ad0394e733cebb91c67281124065 100644 (file)
@@ -167,6 +167,12 @@ class RegressionTests(unittest.TestCase):
         self.assertRaises(UnicodeEncodeError, setattr, con,
                           "isolation_level", u"\xe9")
 
+    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")
index 309b16852cd082ee799cac9fa376c8d310abdc22..7ee11a988ffbed0ed12d977e902b7cc8848e55bb 100644 (file)
@@ -1051,6 +1051,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) {