mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545)
This commit is contained in:
parent
f171877ebe
commit
fa106a685c
3 changed files with 23 additions and 7 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue