summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test/regression.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-09-17 07:35:44 (GMT)
committerGitHub <noreply@github.com>2020-09-17 07:35:44 (GMT)
commit0b419b791077414bbc011a412698ebb362b63761 (patch)
treeee14bf8c868781a6d75c080acbaf110c94ae6270 /Lib/sqlite3/test/regression.py
parentdcfaa520c4638a67052a4ff4a2a820be68750ad7 (diff)
downloadcpython-0b419b791077414bbc011a412698ebb362b63761.zip
cpython-0b419b791077414bbc011a412698ebb362b63761.tar.gz
cpython-0b419b791077414bbc011a412698ebb362b63761.tar.bz2
bpo-41662: Fix bugs in binding parameters in sqlite3 (GH-21998)
* When the parameters argument is a list, correctly handle the case of changing it during iteration. * When the parameters argument is a custom sequence, no longer override an exception raised in ``__len__()``.
Diffstat (limited to 'Lib/sqlite3/test/regression.py')
-rw-r--r--Lib/sqlite3/test/regression.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 0735a5c..67557e1 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -132,6 +132,19 @@ class RegressionTests(unittest.TestCase):
con.execute("insert into foo(bar) values (5)")
con.execute(SELECT)
+ def CheckBindMutatingList(self):
+ # Issue41662: Crash when mutate a list of parameters during iteration.
+ class X:
+ def __conform__(self, protocol):
+ parameters.clear()
+ return "..."
+ parameters = [X(), 0]
+ con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES)
+ con.execute("create table foo(bar X, baz integer)")
+ # Should not crash
+ with self.assertRaises(IndexError):
+ con.execute("insert into foo(bar, baz) values (?, ?)", parameters)
+
def CheckErrorMsgDecodeError(self):
# When porting the module to Python 3.0, the error message about
# decoding errors disappeared. This verifies they're back again.