'cursor.mogrify()' can be called on closed cursors

Fix #579.
This commit is contained in:
Daniele Varrazzo 2018-01-10 23:06:31 +00:00
parent 04f1f06b9f
commit e0226fc46a
3 changed files with 7 additions and 2 deletions

1
NEWS
View File

@ -18,6 +18,7 @@ What's new in psycopg 2.7.4
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed Solaris 10 support (:ticket:`#532`).
- `cursor.mogrify()` can be called on closed cursors (:ticket:`#579`).
- Fixed `~psycopg2.extras.MinTimeLoggingCursor` on Python 3 (:ticket:`#609`).
- Fixed parsing of array of points as floats (:ticket:`#613`).
- Fixed `~psycopg2.__libpq_version__` building with libpq >= 10.1

View File

@ -592,8 +592,6 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs)
return NULL;
}
EXC_IF_CURS_CLOSED(self);
return _psyco_curs_mogrify(self, operation, vars);
}

View File

@ -118,6 +118,12 @@ class CursorTests(ConnectingTestCase):
nref2 = sys.getrefcount(foo)
self.assertEqual(nref1, nref2)
def test_modify_closed(self):
cur = self.conn.cursor()
cur.close()
sql = cur.mogrify("select %s", (10,))
self.assertEqual(sql, b"select 10")
def test_bad_placeholder(self):
cur = self.conn.cursor()
self.assertRaises(psycopg2.ProgrammingError,