]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- _cursor_execute() will close the cursor on error; oracle doesn't allow double close
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Jan 2014 02:20:54 +0000 (21:20 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Jan 2014 02:20:54 +0000 (21:20 -0500)
- ensure no iterator changed size issues in testing.engines

lib/sqlalchemy/engine/default.py
lib/sqlalchemy/testing/engines.py

index bcb9960b12ffe3aaeebad2f69d0728a52f47e73d..c1c012d33e8e67745431d95836385e4a298086bc 100644 (file)
@@ -240,20 +240,20 @@ class DefaultDialect(interfaces.Dialect):
             parameters = {}
 
         def check_unicode(test):
-            cursor = connection.connection.cursor()
+            statement = cast_to(expression.select([test]).compile(dialect=self))
             try:
-                try:
-                    statement = cast_to(expression.select([test]).compile(dialect=self))
-                    connection._cursor_execute(cursor, statement, parameters)
-                    row = cursor.fetchone()
-
-                    return isinstance(row[0], util.text_type)
-                except exc.DBAPIError as de:
-                    util.warn("Exception attempting to "
-                            "detect unicode returns: %r" % de)
-                    return False
-            finally:
+                cursor = connection.connection.cursor()
+                connection._cursor_execute(cursor, statement, parameters)
+                row = cursor.fetchone()
                 cursor.close()
+            except exc.DBAPIError as de:
+                # note that _cursor_execute() will have closed the cursor
+                # if an exception is thrown.
+                util.warn("Exception attempting to "
+                        "detect unicode returns: %r" % de)
+                return False
+            else:
+                return isinstance(row[0], util.text_type)
 
         tests = [
             # detect plain VARCHAR
index a74bffe26ba8d4a2b0dc1edffd566cd383191235..d85771f8a09d17d8bca74577db3e3137b46db019 100644 (file)
@@ -61,7 +61,7 @@ class ConnectionKiller(object):
         # is collecting in finalize_fairy, deadlock.
         # not sure if this should be if pypy/jython only.
         # note that firebird/fdb definitely needs this though
-        for conn, rec in self.conns:
+        for conn, rec in list(self.conns):
             self._safe(conn.rollback)
 
     def _stop_test_ctx(self):
@@ -81,7 +81,7 @@ class ConnectionKiller(object):
 
     def _stop_test_ctx_aggressive(self):
         self.close_all()
-        for conn, rec in self.conns:
+        for conn, rec in list(self.conns):
             self._safe(conn.close)
             rec.connection = None