mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-15 05:26:37 +03:00
Merge branch 'fix-716' into maint_2_7
This commit is contained in:
commit
85ec17a313
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ What's new in psycopg 2.7.5
|
||||||
(:ticket:`#677`).
|
(:ticket:`#677`).
|
||||||
- Maybe fixed building on MSYS2 (as reported in :ticket:`#658`).
|
- Maybe fixed building on MSYS2 (as reported in :ticket:`#658`).
|
||||||
- Allow string subclasses in connection and other places (:ticket:`#679`).
|
- Allow string subclasses in connection and other places (:ticket:`#679`).
|
||||||
|
- Don't raise an exception closing an unused named cursor (:ticket:`#716`).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.7.4
|
What's new in psycopg 2.7.4
|
||||||
|
|
|
@ -59,6 +59,11 @@ psyco_curs_close(cursorObject *self)
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
PGTransactionStatusType status;
|
PGTransactionStatusType status;
|
||||||
|
|
||||||
|
if (!self->query) {
|
||||||
|
Dprintf("skipping named cursor close because unused");
|
||||||
|
goto close;
|
||||||
|
}
|
||||||
|
|
||||||
if (self->conn) {
|
if (self->conn) {
|
||||||
status = PQtransactionStatus(self->conn->pgconn);
|
status = PQtransactionStatus(self->conn->pgconn);
|
||||||
}
|
}
|
||||||
|
@ -66,17 +71,18 @@ psyco_curs_close(cursorObject *self)
|
||||||
status = PQTRANS_UNKNOWN;
|
status = PQTRANS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(status == PQTRANS_UNKNOWN || status == PQTRANS_INERROR)) {
|
if (status == PQTRANS_UNKNOWN || status == PQTRANS_INERROR) {
|
||||||
|
Dprintf("skipping named curs close because tx status %d",
|
||||||
|
(int)status);
|
||||||
|
goto close;
|
||||||
|
}
|
||||||
|
|
||||||
EXC_IF_NO_MARK(self);
|
EXC_IF_NO_MARK(self);
|
||||||
PyOS_snprintf(buffer, 127, "CLOSE %s", self->qname);
|
PyOS_snprintf(buffer, 127, "CLOSE %s", self->qname);
|
||||||
if (pq_execute(self, buffer, 0, 0, 1) == -1) return NULL;
|
if (pq_execute(self, buffer, 0, 0, 1) == -1) return NULL;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Dprintf("skipping named curs close because tx status %d",
|
|
||||||
(int)status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
close:
|
||||||
self->closed = 1;
|
self->closed = 1;
|
||||||
Dprintf("psyco_curs_close: cursor at %p closed", self);
|
Dprintf("psyco_curs_close: cursor at %p closed", self);
|
||||||
|
|
||||||
|
|
|
@ -443,6 +443,11 @@ class CursorTests(ConnectingTestCase):
|
||||||
self.assertEqual([(2,), (3,), (4,)], cur2.fetchmany(3))
|
self.assertEqual([(2,), (3,), (4,)], cur2.fetchmany(3))
|
||||||
self.assertEqual([(5,), (6,), (7,)], cur2.fetchall())
|
self.assertEqual([(5,), (6,), (7,)], cur2.fetchall())
|
||||||
|
|
||||||
|
@skip_before_postgres(8, 0)
|
||||||
|
def test_named_noop_close(self):
|
||||||
|
cur = self.conn.cursor('test')
|
||||||
|
cur.close()
|
||||||
|
|
||||||
@skip_before_postgres(8, 0)
|
@skip_before_postgres(8, 0)
|
||||||
def test_scroll(self):
|
def test_scroll(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
|
|
|
@ -28,7 +28,7 @@ from __future__ import with_statement
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions as ext
|
import psycopg2.extensions as ext
|
||||||
|
|
||||||
from testutils import unittest, ConnectingTestCase
|
from testutils import unittest, ConnectingTestCase, skip_before_postgres
|
||||||
|
|
||||||
|
|
||||||
class WithTestCase(ConnectingTestCase):
|
class WithTestCase(ConnectingTestCase):
|
||||||
|
@ -217,6 +217,11 @@ class WithCursorTestCase(WithTestCase):
|
||||||
else:
|
else:
|
||||||
self.fail("where is my exception?")
|
self.fail("where is my exception?")
|
||||||
|
|
||||||
|
@skip_before_postgres(8, 0)
|
||||||
|
def test_named_with_noop(self):
|
||||||
|
with self.conn.cursor('named') as cur:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user