diff options
author | Petri Lehtinen <petri@digip.org> | 2011-05-09 10:24:09 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2012-02-06 20:04:18 (GMT) |
commit | 4a84f58143ca01db181f28df06ac922fbf73a1d7 (patch) | |
tree | 24c9d7be2e2ca971d41ae7f7bd23ebf9d57e380f /Lib | |
parent | 1f30575713a153d5b3c558de6068bdfe1dd1a3f4 (diff) | |
download | cpython-4a84f58143ca01db181f28df06ac922fbf73a1d7.zip cpython-4a84f58143ca01db181f28df06ac922fbf73a1d7.tar.gz cpython-4a84f58143ca01db181f28df06ac922fbf73a1d7.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.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 7d0553d..c7551e3 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -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,)) |