[pypy-commit] pypy default: test and fix segfault in _sqlite3.Connection.total_changes after close()
bdkearns
noreply at buildbot.pypy.org
Tue Mar 5 01:36:57 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r62032:88af669ec637
Date: 2013-03-04 19:36 -0500
http://bitbucket.org/pypy/pypy/changeset/88af669ec637/
Log: test and fix segfault in _sqlite3.Connection.total_changes after
close()
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -529,6 +529,7 @@
self.rollback()
def _get_total_changes(self):
+ self._check_closed()
return sqlite.sqlite3_total_changes(self.db)
total_changes = property(_get_total_changes)
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -21,6 +21,11 @@
result = list(cursor)
assert result == [(42,)]
+def test_total_changes_after_close():
+ con = _sqlite3.connect(':memory:')
+ con.close()
+ pytest.raises(_sqlite3.ProgrammingError, "con.total_changes")
+
def test_connection_check_init():
class Connection(_sqlite3.Connection):
def __init__(self, name):
More information about the pypy-commit
mailing list