]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Raise InterfaceError on operation on closed objects
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Oct 2020 16:45:03 +0000 (17:45 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Oct 2020 21:05:58 +0000 (22:05 +0100)
psycopg3/psycopg3/cursor.py
tests/test_cursor.py
tests/test_cursor_async.py

index 236165621880b4f838109b26b740367145c59985..31ccc3fa3a17a3ad699303cecce083e7d16d24fa 100644 (file)
@@ -142,10 +142,10 @@ class BaseCursor:
         from .adapt import Transformer
 
         if self.closed:
-            raise e.OperationalError("the cursor is closed")
+            raise e.InterfaceError("the cursor is closed")
 
         if self.connection.closed:
-            raise e.OperationalError("the connection is closed")
+            raise e.InterfaceError("the connection is closed")
 
         if self.connection.status != self.connection.ConnStatus.OK:
             raise e.InterfaceError(
index a50b9bbecdb03e8c7b407d97baaf630023f986f0..b874af29406c1c83227fd25a224d8f84a2437cfd 100644 (file)
@@ -11,7 +11,7 @@ def test_close(conn):
     cur.close()
     assert cur.closed
 
-    with pytest.raises(psycopg3.OperationalError):
+    with pytest.raises(psycopg3.InterfaceError):
         cur.execute("select 'foo'")
 
     cur.close()
index 37598b950f2913282a190dd75e64d373df7be343..53c3cf2a32e08afc719ece54a730ccc115441eb8 100644 (file)
@@ -13,7 +13,7 @@ async def test_close(aconn):
     await cur.close()
     assert cur.closed
 
-    with pytest.raises(psycopg3.OperationalError):
+    with pytest.raises(psycopg3.InterfaceError):
         await cur.execute("select 'foo'")
 
     await cur.close()