mirror of
https://github.com/python/cpython.git
synced 2025-07-21 18:25:22 +00:00
Issue #10811: Fix recursive usage of cursors. Instead of crashing, raise a ProgrammingError now.
This commit is contained in:
parent
1f30575713
commit
4a84f58143
4 changed files with 45 additions and 10 deletions
|
@ -281,6 +281,28 @@ class RegressionTests(unittest.TestCase):
|
|||
# Lone surrogate cannot be encoded to the default encoding (utf8)
|
||||
"\uDC80", collation_cb)
|
||||
|
||||
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,))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue