summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2018-10-12 23:31:34 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2018-10-12 23:31:34 +0100
commitba9f37022a4cd7db13c2a32d800ac7136dcaeea4 (patch)
tree96f1ea33388d12b574fd15c425ad18a4e9dd12d9
parent74fd0ec0633d6db3225b86d18cef96cbbce84335 (diff)
parented6f32999f7303e9b8823a03c1a4cf261bb81fcd (diff)
downloadpsycopg2-ba9f37022a4cd7db13c2a32d800ac7136dcaeea4.tar.gz
Merge branch 'fix-790' into maint_2_7
-rw-r--r--NEWS2
-rw-r--r--psycopg/connection_type.c2
-rwxr-xr-xtests/test_connection.py8
3 files changed, 12 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index ab86b7d..12c06a2 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ What's new in psycopg 2.7.6
(:ticket:`#746`).
- Fixed building on modern FreeBSD versions with Python 3.7 (:ticket:`#755`).
- Fixed hang trying to :sql:`COPY` via `~cursor.execute()` (:ticket:`#781`).
+- Fixed segfault accessing the `connection.readonly` and
+ `connection.deferrable` repeatedly (:ticket:`#790`).
What's new in psycopg 2.7.5
diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c
index 6a66d48..8ecb356 100644
--- a/psycopg/connection_type.c
+++ b/psycopg/connection_type.c
@@ -757,6 +757,7 @@ psyco_conn_readonly_get(connectionObject *self)
break;
}
+ Py_XINCREF(rv);
return rv;
}
@@ -803,6 +804,7 @@ psyco_conn_deferrable_get(connectionObject *self)
break;
}
+ Py_XINCREF(rv);
return rv;
}
diff --git a/tests/test_connection.py b/tests/test_connection.py
index d8b86d7..15d0040 100755
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -804,6 +804,14 @@ class IsolationLevelsTestCase(ConnectingTestCase):
self.assertRaises(ValueError, setattr, self.conn, 'isolation_level', 5)
self.assertRaises(ValueError, setattr, self.conn, 'isolation_level', 'bah')
+ def test_attribs_segfault(self):
+ # bug #790
+ for i in range(10000):
+ self.conn.autocommit
+ self.conn.readonly
+ self.conn.deferrable
+ self.conn.isolation_level
+
class ConnectionTwoPhaseTests(ConnectingTestCase):
def setUp(self):