summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-05 03:09:40 (GMT)
committerGitHub <noreply@github.com>2021-06-05 03:09:40 (GMT)
commitad2f3b74b5615aa36a82d1fdbc45bb7468aa1d72 (patch)
tree9e462a2a700aeb224284a8cdde5f1a3fff78bfff /Lib/sqlite3
parent4642caf232a3f01468e76f19cd0c88175e10ee28 (diff)
downloadcpython-ad2f3b74b5615aa36a82d1fdbc45bb7468aa1d72.zip
cpython-ad2f3b74b5615aa36a82d1fdbc45bb7468aa1d72.tar.gz
cpython-ad2f3b74b5615aa36a82d1fdbc45bb7468aa1d72.tar.bz2
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545)
(cherry picked from commit fa106a685c1f199aca5be5c2d0277a14cc9057bd) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r--Lib/sqlite3/test/userfunctions.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index 6f57d19..4290890 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -23,6 +23,7 @@
import unittest
import unittest.mock
+import gc
import sqlite3 as sqlite
def func_returntext():
@@ -322,6 +323,22 @@ class FunctionTests(unittest.TestCase):
with self.assertRaises(TypeError):
self.con.create_function("deterministic", 0, int, True)
+ def test_function_destructor_via_gc(self):
+ # See bpo-44304: The destructor of the user function can
+ # crash if is called without the GIL from the gc functions
+ dest = sqlite.connect(':memory:')
+ def md5sum(t):
+ return
+
+ dest.create_function("md5", 1, md5sum)
+ x = dest("create table lang (name, first_appeared)")
+ del md5sum, dest
+
+ y = [x]
+ y.append(y)
+
+ del x,y
+ gc.collect()
class AggregateTests(unittest.TestCase):
def setUp(self):