Visitar URL original
bpo-44859: Raise more accurate exceptions in `sqlite3` by erlend-aasland · Pull Request #27695 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review: add tests for PyObject_GetBuffer failures
  • Loading branch information
Erlend E. Aasland
Erlend E. Aasland committed Feb 26, 2022
commit b4a95bdb096d379bc1698778a1506537224ea660
8 changes: 8 additions & 0 deletions Lib/test/test_sqlite3/test_userfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def setUp(self):
self.con.create_function("returnlonglong", 0, func_returnlonglong)
self.con.create_function("returnnan", 0, lambda: float("nan"))
self.con.create_function("returntoolargeint", 0, lambda: 1 << 65)
self.con.create_function("return_noncont_blob", 0,
lambda: memoryview(b"blob")[::2])
self.con.create_function("raiseexception", 0, func_raiseexception)
self.con.create_function("memoryerror", 0, func_memoryerror)
self.con.create_function("overflowerror", 0, func_overflowerror)
Expand Down Expand Up @@ -345,6 +347,12 @@ def test_non_contiguous_blob(self):
self.con.execute, "select spam(?)",
(memoryview(b"blob")[::2],))

@with_tracebacks(BufferError, regex="buffer.*contiguous")
def test_return_non_contiguous_blob(self):
with self.assertRaises(sqlite.OperationalError):
cur = self.con.execute("select return_noncont_blob()")
cur.fetchone()

def test_param_surrogates(self):
self.assertRaisesRegex(UnicodeEncodeError, "surrogates not allowed",
self.con.execute, "select spam(?)",
Expand Down