diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-01-11 00:16:01 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-01-11 00:16:01 +0000 |
commit | 6da3e7ee69971cd6cb692765a4d66a5ce405f104 (patch) | |
tree | ba958560605a1b35198722e54ca38eae5397ae0e | |
parent | ddef2e30cd080c21f4a52a757c642069ceb935c5 (diff) | |
parent | e0226fc46ad21f10ca612b32659bab442d2db871 (diff) | |
download | psycopg2-6da3e7ee69971cd6cb692765a4d66a5ce405f104.tar.gz |
Merge branch 'mogrify-on-closed-cursor'
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | psycopg/cursor_type.c | 2 | ||||
-rwxr-xr-x | tests/test_cursor.py | 6 |
3 files changed, 7 insertions, 2 deletions
@@ -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 diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index a70e9d3..b7fd187 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -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); } diff --git a/tests/test_cursor.py b/tests/test_cursor.py index ec76918..cc8db0f 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -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, |