summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r--Lib/sqlite3/dbapi2.py2
-rw-r--r--Lib/sqlite3/test/dbapi.py2
-rw-r--r--Lib/sqlite3/test/types.py6
-rw-r--r--Lib/sqlite3/test/userfunctions.py17
4 files changed, 14 insertions, 13 deletions
diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py
index 7eb28e8..52fb4ae 100644
--- a/Lib/sqlite3/dbapi2.py
+++ b/Lib/sqlite3/dbapi2.py
@@ -50,7 +50,7 @@ def TimestampFromTicks(ticks):
version_info = tuple([int(x) for x in version.split(".")])
sqlite_version_info = tuple([int(x) for x in sqlite_version.split(".")])
-Binary = buffer
+Binary = memoryview
def register_adapters_and_converters():
def adapt_date(val):
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index faf31b1..6d4c4fe 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -593,7 +593,7 @@ class ConstructorTests(unittest.TestCase):
ts = sqlite.TimestampFromTicks(42)
def CheckBinary(self):
- b = sqlite.Binary(chr(0) + "'")
+ b = sqlite.Binary(b"\0'")
class ExtensionTests(unittest.TestCase):
def CheckScriptStringSql(self):
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py
index 20f0093..1377835 100644
--- a/Lib/sqlite3/test/types.py
+++ b/Lib/sqlite3/test/types.py
@@ -62,7 +62,7 @@ class SqliteTypeTests(unittest.TestCase):
self.failUnlessEqual(row[0], val)
def CheckBlob(self):
- val = buffer(b"Guglhupf")
+ val = memoryview(b"Guglhupf")
self.cur.execute("insert into test(b) values (?)", (val,))
self.cur.execute("select b from test")
row = self.cur.fetchone()
@@ -203,7 +203,7 @@ class DeclTypesTests(unittest.TestCase):
def CheckBlob(self):
# default
- val = buffer(b"Guglhupf")
+ val = memoryview(b"Guglhupf")
self.cur.execute("insert into test(bin) values (?)", (val,))
self.cur.execute("select bin from test")
row = self.cur.fetchone()
@@ -305,7 +305,7 @@ class BinaryConverterTests(unittest.TestCase):
def CheckBinaryInputForConverter(self):
testdata = b"abcdefg" * 10
- result = self.con.execute('select ? as "x [bin]"', (buffer(bz2.compress(testdata)),)).fetchone()[0]
+ result = self.con.execute('select ? as "x [bin]"', (memoryview(bz2.compress(testdata)),)).fetchone()[0]
self.failUnlessEqual(testdata, result)
class DateTimeTests(unittest.TestCase):
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)