summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test/userfunctions.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sqlite3/test/userfunctions.py')
-rw-r--r--Lib/sqlite3/test/userfunctions.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index ab4f756..994057e 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -36,7 +36,7 @@ def func_returnfloat():
def func_returnnull():
return None
def func_returnblob():
- return buffer(b"blob")
+ return b"blob"
def func_raiseexception():
5/0
@@ -49,7 +49,7 @@ def func_isfloat(v):
def func_isnone(v):
return type(v) is type(None)
def func_isblob(v):
- return type(v) is buffer
+ return isinstance(v, (bytes, memoryview))
class AggrNoStep:
def __init__(self):
@@ -100,7 +100,8 @@ class AggrCheckType:
self.val = None
def step(self, whichType, val):
- theType = {"str": str, "int": int, "float": float, "None": type(None), "blob": buffer}
+ theType = {"str": str, "int": int, "float": float, "None": type(None),
+ "blob": bytes}
self.val = int(theType[whichType] is type(val))
def finalize(self):
@@ -196,8 +197,8 @@ class FunctionTests(unittest.TestCase):
cur = self.con.cursor()
cur.execute("select returnblob()")
val = cur.fetchone()[0]
- self.failUnlessEqual(type(val), buffer)
- self.failUnlessEqual(val, buffer(b"blob"))
+ self.failUnlessEqual(type(val), bytes)
+ self.failUnlessEqual(val, memoryview(b"blob"))
def CheckFuncException(self):
cur = self.con.cursor()
@@ -234,7 +235,7 @@ class FunctionTests(unittest.TestCase):
def CheckParamBlob(self):
cur = self.con.cursor()
- cur.execute("select isblob(?)", (buffer(b"blob"),))
+ cur.execute("select isblob(?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.failUnlessEqual(val, 1)
@@ -252,7 +253,7 @@ class AggregateTests(unittest.TestCase):
)
""")
cur.execute("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)",
- ("foo", 5, 3.14, None, buffer(b"blob"),))
+ ("foo", 5, 3.14, None, memoryview(b"blob"),))
self.con.create_aggregate("nostep", 1, AggrNoStep)
self.con.create_aggregate("nofinalize", 1, AggrNoFinalize)
@@ -344,7 +345,7 @@ class AggregateTests(unittest.TestCase):
def CheckAggrCheckParamBlob(self):
cur = self.con.cursor()
- cur.execute("select checkType('blob', ?)", (buffer(b"blob"),))
+ cur.execute("select checkType('blob', ?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.failUnlessEqual(val, 1)