]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug in connection pool cursor wrapper whereby if a
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Apr 2010 20:16:56 +0000 (16:16 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Apr 2010 20:16:56 +0000 (16:16 -0400)
cursor threw an exception on close(), the logging of the
message would fail.  [ticket:1786]

CHANGES
lib/sqlalchemy/pool.py
test/engine/test_reconnect.py

diff --git a/CHANGES b/CHANGES
index e66480da51f041b1fd6bb5aef88c172510702b72..0bc7275b9611ea15c971faf10ead1b47dcaf0ab6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,10 @@ CHANGES
   - Fixed "table" argument on constructor of ForeginKeyConstraint
     [ticket:1571]
 
+  - Fixed bug in connection pool cursor wrapper whereby if a
+    cursor threw an exception on close(), the logging of the 
+    message would fail.  [ticket:1786]
+    
 - engines
   - Fixed building the C extensions on Python 2.4. [ticket:1781]
     
index 31ab7facc5027eb39d36f06a829ab39882c8c7b8..ef132389297121a50757e8c943a89f7f39e81874 100644 (file)
@@ -454,7 +454,7 @@ class _CursorFairy(object):
                 ex_text = str(e)
             except TypeError:
                 ex_text = repr(e)
-            self.__parent._logger.warn("Error closing cursor: %s", ex_text)
+            self._parent._logger.warn("Error closing cursor: %s", ex_text)
 
             if isinstance(e, (SystemExit, KeyboardInterrupt)):
                 raise
index 6afd7151554f12939c25423368a3c37de84138d1..117ef05eeabb8fa76967e523c2500e1b360873fd 100644 (file)
@@ -177,6 +177,34 @@ class MockReconnectTest(TestBase):
         assert not conn.invalidated
         assert len(dbapi.connections) == 1
 
+class CursorErrTest(TestBase):
+
+    def setup(self):
+        global db, dbapi
+        
+        class MDBAPI(MockDBAPI):
+            def connect(self, *args, **kwargs):
+                return MConn(self)
+            
+        class MConn(MockConnection):
+            def cursor(self):
+                return MCursor(self)
+
+        class MCursor(MockCursor):
+            def close(self):
+                raise Exception("explode")
+
+        dbapi = MDBAPI()
+
+        # create engine using our current dburi
+        db = tsa.create_engine('postgresql://foo:bar@localhost/test', module=dbapi, _initialize=False)
+    
+    def test_cursor_explode(self):
+        conn = db.connect()
+        result = conn.execute("select foo")
+        result.close()
+        conn.close()
+        
 engine = None
 class RealReconnectTest(TestBase):
     def setup(self):