mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
This commit is contained in:
parent
9482032761
commit
7857650833
3 changed files with 89 additions and 0 deletions
|
@ -744,6 +744,73 @@ class ClosedTests(unittest.TestCase):
|
|||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
|
||||
def CheckClosedCreateFunction(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.close()
|
||||
def f(x): return 17
|
||||
try:
|
||||
con.create_function("foo", 1, f)
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
def CheckClosedCreateAggregate(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.close()
|
||||
class Agg:
|
||||
def __init__(self):
|
||||
pass
|
||||
def step(self, x):
|
||||
pass
|
||||
def finalize(self):
|
||||
return 17
|
||||
try:
|
||||
con.create_aggregate("foo", 1, Agg)
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
def CheckClosedSetAuthorizer(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.close()
|
||||
def authorizer(*args):
|
||||
return sqlite.DENY
|
||||
try:
|
||||
con.set_authorizer(authorizer)
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
def CheckClosedSetProgressCallback(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.close()
|
||||
def progress(): pass
|
||||
try:
|
||||
con.set_progress_handler(progress, 100)
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
def CheckClosedCall(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.close()
|
||||
try:
|
||||
con()
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("Should have raised a ProgrammingError")
|
||||
|
||||
def suite():
|
||||
module_suite = unittest.makeSuite(ModuleTests, "Check")
|
||||
connection_suite = unittest.makeSuite(ConnectionTests, "Check")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue