diff options
author | Guido van Rossum <guido@python.org> | 2007-10-08 02:46:15 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-08 02:46:15 +0000 |
commit | bae07c9baf3e53164de6f85a18ce747a76b9ffde (patch) | |
tree | e0bf84063848730026bea64461fe3920dbe8ecb8 /Lib/sqlite3/test/userfunctions.py | |
parent | 85c1ba5d742779eec3148377ce6d8d359d318263 (diff) | |
download | cpython-git-bae07c9baf3e53164de6f85a18ce747a76b9ffde.tar.gz |
Breaking ground for PEP 3137 implementation:
Get rid of buffer(). Use memoryview() in its place where possible.
In a few places, do things a bit different, because memoryview()
can't slice (yet).
Diffstat (limited to 'Lib/sqlite3/test/userfunctions.py')
-rw-r--r-- | Lib/sqlite3/test/userfunctions.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py index ab4f7568d6..994057e945 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) |