[Python-checkins] r79203 - in python/branches/release26-maint: Lib/sqlite3/test/regression.py Modules/_sqlite/connection.c

victor.stinner python-checkins at python.org
Sun Mar 21 14:52:56 CET 2010


Author: victor.stinner
Date: Sun Mar 21 14:52:56 2010
New Revision: 79203

Log:
Merged revisions 78898 via svnmerge from 
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:").
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/sqlite3/test/regression.py
   python/branches/release26-maint/Modules/_sqlite/connection.c

Modified: python/branches/release26-maint/Lib/sqlite3/test/regression.py
==============================================================================
--- python/branches/release26-maint/Lib/sqlite3/test/regression.py	(original)
+++ python/branches/release26-maint/Lib/sqlite3/test/regression.py	Sun Mar 21 14:52:56 2010
@@ -167,6 +167,12 @@
         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")

Modified: python/branches/release26-maint/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/release26-maint/Modules/_sqlite/connection.c	(original)
+++ python/branches/release26-maint/Modules/_sqlite/connection.c	Sun Mar 21 14:52:56 2010
@@ -1051,6 +1051,12 @@
         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) {


More information about the Python-checkins mailing list