summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test
diff options
context:
space:
mode:
authorPeter McCormick <peter@pdmccormick.com>2020-09-20 03:40:46 (GMT)
committerGitHub <noreply@github.com>2020-09-20 03:40:46 (GMT)
commitbfee9fad84531a471fd7864e88947320669f68e2 (patch)
tree23627320837bd9104bc215ed274fc07eafce0b44 /Lib/sqlite3/test
parentc8c70e78762315643fcd132911bad38842a3e8af (diff)
downloadcpython-bfee9fad84531a471fd7864e88947320669f68e2.zip
cpython-bfee9fad84531a471fd7864e88947320669f68e2.tar.gz
cpython-bfee9fad84531a471fd7864e88947320669f68e2.tar.bz2
bpo-41815: SQLite: segfault if backup called on closed database (GH-22322)
# [bpo-41815](): SQLite: fix segfault if backup called on closed database Attempting to backup a closed database will trigger segfault: ```python import sqlite3 target = sqlite3.connect(':memory:') source = sqlite3.connect(':memory:') source.close() source.backup(target) ```
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r--Lib/sqlite3/test/backup.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/backup.py b/Lib/sqlite3/test/backup.py
index 2752a4d..3637c4b 100644
--- a/Lib/sqlite3/test/backup.py
+++ b/Lib/sqlite3/test/backup.py
@@ -35,6 +35,13 @@ class BackupTests(unittest.TestCase):
with self.assertRaises(sqlite.ProgrammingError):
self.cx.backup(bck)
+ def test_bad_source_closed_connection(self):
+ bck = sqlite.connect(':memory:')
+ source = sqlite.connect(":memory:")
+ source.close()
+ with self.assertRaises(sqlite.ProgrammingError):
+ source.backup(bck)
+
def test_bad_target_in_transaction(self):
bck = sqlite.connect(':memory:')
bck.execute('CREATE TABLE bar (key INTEGER)')