FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-44958: Fix ref. leak introduced in GH-27844 by erlend-aasland · Pull Request #28490 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions Lib/sqlite3/test/test_dbapi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@

# Helper for tests using TESTFN
@contextlib.contextmanager
def managed_connect(*args, **kwargs):
def managed_connect(*args, in_mem=False, **kwargs):
cx = sqlite.connect(*args, **kwargs)
try:
yield cx
finally:
cx.close()
unlink(TESTFN)
if not in_mem:
unlink(TESTFN)


class ModuleTests(unittest.TestCase):
Expand Down
61 changes: 33 additions & 28 deletions Lib/sqlite3/test/test_regression.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import functools
from test import support

from .test_dbapi import managed_connect

class RegressionTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
Expand Down Expand Up @@ -437,38 +439,41 @@ def test_return_empty_bytestring(self):
self.assertEqual(val, b'')

def test_table_lock_cursor_replace_stmt(self):
con = sqlite.connect(":memory:")
cur = con.cursor()
cur.execute("create table t(t)")
cur.executemany("insert into t values(?)", ((v,) for v in range(5)))
con.commit()
cur.execute("select t from t")
cur.execute("drop table t")
con.commit()
with managed_connect(":memory:", in_mem=True) as con:
cur = con.cursor()
cur.execute("create table t(t)")
cur.executemany("insert into t values(?)",
((v,) for v in range(5)))
con.commit()
cur.execute("select t from t")
cur.execute("drop table t")
con.commit()

def test_table_lock_cursor_dealloc(self):
con = sqlite.connect(":memory:")
con.execute("create table t(t)")
con.executemany("insert into t values(?)", ((v,) for v in range(5)))
con.commit()
cur = con.execute("select t from t")
del cur
con.execute("drop table t")
con.commit()
with managed_connect(":memory:", in_mem=True) as con:
con.execute("create table t(t)")
con.executemany("insert into t values(?)",
((v,) for v in range(5)))
con.commit()
cur = con.execute("select t from t")
del cur
con.execute("drop table t")
con.commit()

def test_table_lock_cursor_non_readonly_select(self):
con = sqlite.connect(":memory:")
con.execute("create table t(t)")
con.executemany("insert into t values(?)", ((v,) for v in range(5)))
con.commit()
def dup(v):
con.execute("insert into t values(?)", (v,))
return
con.create_function("dup", 1, dup)
cur = con.execute("select dup(t) from t")
del cur
con.execute("drop table t")
con.commit()
with managed_connect(":memory:", in_mem=True) as con:
con.execute("create table t(t)")
con.executemany("insert into t values(?)",
((v,) for v in range(5)))
con.commit()
def dup(v):
con.execute("insert into t values(?)", (v,))
return
con.create_function("dup", 1, dup)
cur = con.execute("select dup(t) from t")
del cur
con.execute("drop table t")
con.commit()


if __name__ == "__main__":
Expand Down

Back | FazBrowse Home | New Git URL