summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-05-09 10:24:09 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-02-06 20:04:00 (GMT)
commitc7fd523ac57a00901901f4278a72346742e0d7b1 (patch)
tree4ad4ee3252cf2c9cea1b73c06eb4db4ee440e130 /Lib
parentcec6a61d303f26c2ca2e7cadf5970f4dff18dc27 (diff)
downloadcpython-c7fd523ac57a00901901f4278a72346742e0d7b1.zip
cpython-c7fd523ac57a00901901f4278a72346742e0d7b1.tar.gz
cpython-c7fd523ac57a00901901f4278a72346742e0d7b1.tar.bz2
Issue #10811: Fix recursive usage of cursors. Instead of crashing, raise a ProgrammingError now.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/sqlite3/test/regression.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 1030061..eec2fcd 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -264,6 +264,28 @@ class RegressionTests(unittest.TestCase):
"""
self.assertRaises(sqlite.Warning, self.con, 1)
+ def CheckRecursiveCursorUse(self):
+ """
+ http://bugs.python.org/issue10811
+
+ Recursively using a cursor, such as when reusing it from a generator led to segfaults.
+ Now we catch recursive cursor usage and raise a ProgrammingError.
+ """
+ con = sqlite.connect(":memory:")
+
+ cur = con.cursor()
+ cur.execute("create table a (bar)")
+ cur.execute("create table b (baz)")
+
+ def foo():
+ cur.execute("insert into a (bar) values (?)", (1,))
+ yield 1
+
+ with self.assertRaises(sqlite.ProgrammingError):
+ cur.executemany("insert into b (baz) values (?)",
+ ((i,) for i in foo()))
+
+
def suite():
regression_suite = unittest.makeSuite(RegressionTests, "Check")
return unittest.TestSuite((regression_suite,))