@@ -36,7 +36,7 @@ def func_returnfloat():
3636def func_returnnull ():
3737 return None
3838def func_returnblob ():
39- return buffer ( b"blob" )
39+ return b"blob"
4040def func_raiseexception ():
4141 5 / 0
4242
@@ -49,7 +49,7 @@ def func_isfloat(v):
4949def func_isnone (v ):
5050 return type (v ) is type (None )
5151def func_isblob (v ):
52- return type ( v ) is buffer
52+ return isinstance ( v , ( bytes , memoryview ))
5353
5454class AggrNoStep :
5555 def __init__ (self ):
@@ -100,7 +100,8 @@ def __init__(self):
100100 self .val = None
101101
102102 def step (self , whichType , val ):
103- theType = {"str" : str , "int" : int , "float" : float , "None" : type (None ), "blob" : buffer }
103+ theType = {"str" : str , "int" : int , "float" : float , "None" : type (None ),
104+ "blob" : bytes }
104105 self .val = int (theType [whichType ] is type (val ))
105106
106107 def finalize (self ):
@@ -196,8 +197,8 @@ def CheckFuncReturnBlob(self):
196197 cur = self .con .cursor ()
197198 cur .execute ("select returnblob()" )
198199 val = cur .fetchone ()[0 ]
199- self .failUnlessEqual (type (val ), buffer )
200- self .failUnlessEqual (val , buffer (b"blob" ))
200+ self .failUnlessEqual (type (val ), bytes )
201+ self .failUnlessEqual (val , memoryview (b"blob" ))
201202
202203 def CheckFuncException (self ):
203204 cur = self .con .cursor ()
@@ -234,7 +235,7 @@ def CheckParamNone(self):
234235
235236 def CheckParamBlob (self ):
236237 cur = self .con .cursor ()
237- cur .execute ("select isblob(?)" , (buffer (b"blob" ),))
238+ cur .execute ("select isblob(?)" , (memoryview (b"blob" ),))
238239 val = cur .fetchone ()[0 ]
239240 self .failUnlessEqual (val , 1 )
240241
@@ -252,7 +253,7 @@ def setUp(self):
252253 )
253254 """ )
254255 cur .execute ("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)" ,
255- ("foo" , 5 , 3.14 , None , buffer (b"blob" ),))
256+ ("foo" , 5 , 3.14 , None , memoryview (b"blob" ),))
256257
257258 self .con .create_aggregate ("nostep" , 1 , AggrNoStep )
258259 self .con .create_aggregate ("nofinalize" , 1 , AggrNoFinalize )
@@ -344,7 +345,7 @@ def CheckAggrCheckParamNone(self):
344345
345346 def CheckAggrCheckParamBlob (self ):
346347 cur = self .con .cursor ()
347- cur .execute ("select checkType('blob', ?)" , (buffer (b"blob" ),))
348+ cur .execute ("select checkType('blob', ?)" , (memoryview (b"blob" ),))
348349 val = cur .fetchone ()[0 ]
349350 self .failUnlessEqual (val , 1 )
350351
0 commit comments