@@ -393,7 +393,7 @@ def read(self, size=0):
393
393
rlen = ffi .new ('ssize_t*' )
394
394
chunk = lib .uwsgi_request_body_read (self .wsgi_req , size , rlen )
395
395
if chunk != ffi .NULL :
396
- return ffi .string (chunk , rlen [0 ])
396
+ return ffi .buffer (chunk , rlen [0 ])[:]
397
397
if rlen [0 ] < 0 :
398
398
raise IOError ("error reading wsgi.input" )
399
399
raise IOError ("error waiting for wsgi.input" )
@@ -402,7 +402,7 @@ def getline(self, hint=0):
402
402
rlen = ffi .new ('ssize_t*' )
403
403
chunk = lib .uwsgi_request_body_readline (self .wsgi_req , hint , rlen )
404
404
if chunk != ffi .NULL :
405
- return ffi .string (chunk , rlen [0 ])
405
+ return ffi .buffer (chunk , rlen [0 ])[:]
406
406
if rlen [0 ] < 0 :
407
407
raise IOError ("error reading line from wsgi.input" )
408
408
raise IOError ("error waiting for line on wsgi.input" )
@@ -521,7 +521,7 @@ def __init__(self, func):
521
521
def __call__ (self , argc , argv , argvs , buf ):
522
522
pargs = []
523
523
for i in range (0 , argc ):
524
- pargs .append (ffi .string (argv [i ], argvs [i ]))
524
+ pargs .append (ffi .buffer (argv [i ], argvs [i ])[:] )
525
525
response = self .func (* pargs )
526
526
if len (response ) > 0 :
527
527
buf [0 ] = lib .uwsgi_malloc (len (response ))
@@ -560,7 +560,7 @@ def uwsgi_pypy_rpc(node, func, *args):
560
560
561
561
response = lib .uwsgi_do_rpc (c_node , ffi .new ("char[]" ,func ), argc , argv , argvs , rsize )
562
562
if response :
563
- ret = ffi .string (response , rsize [0 ])
563
+ ret = ffi .buffer (response , rsize [0 ])[:]
564
564
lib .free (response )
565
565
return ret
566
566
return None
@@ -587,7 +587,7 @@ def uwsgi_pypy_uwsgi_cache_get(key, cache=ffi.NULL):
587
587
value = lib .uwsgi_cache_magic_get (key , len (key ), vallen , ffi .NULL , cache )
588
588
if value == ffi .NULL :
589
589
return None
590
- ret = ffi .string (value , vallen [0 ])
590
+ ret = ffi .buffer (value , vallen [0 ])[:]
591
591
libc .free (value )
592
592
return ret
593
593
uwsgi .cache_get = uwsgi_pypy_uwsgi_cache_get
@@ -617,8 +617,9 @@ def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
617
617
uci = ffi .new ('struct uwsgi_cache_item **' )
618
618
while True :
619
619
uci [0 ] = lib .uwsgi_cache_keys (uc , pos , uci )
620
- if uci [0 ] == ffi .NULL : break
621
- l .append (ffi .string (lib .uwsgi_cache_item_key (uci [0 ]), uci [0 ].keysize ))
620
+ if uci [0 ] == ffi .NULL :
621
+ break
622
+ l .append (ffi .buffer (lib .uwsgi_cache_item_key (uci [0 ]), uci [0 ].keysize )[:])
622
623
lib .uwsgi_cache_rwunlock (uc )
623
624
return l
624
625
uwsgi .cache_keys = uwsgi_pypy_uwsgi_cache_keys
@@ -849,7 +850,7 @@ def uwsgi_pypy_websocket_recv():
849
850
ub = lib .uwsgi_websocket_recv (wsgi_req );
850
851
if ub == ffi .NULL :
851
852
raise IOError ("unable to receive websocket message" )
852
- ret = ffi .string (ub .buf , ub .pos )
853
+ ret = ffi .buffer (ub .buf , ub .pos )[:]
853
854
lib .uwsgi_buffer_destroy (ub )
854
855
return ret
855
856
uwsgi .websocket_recv = uwsgi_pypy_websocket_recv
@@ -862,7 +863,7 @@ def uwsgi_pypy_websocket_recv_nb():
862
863
ub = lib .uwsgi_websocket_recv_nb (wsgi_req );
863
864
if ub == ffi .NULL :
864
865
raise IOError ("unable to receive websocket message" )
865
- ret = ffi .string (ub .buf , ub .pos )
866
+ ret = ffi .buffer (ub .buf , ub .pos )[:]
866
867
lib .uwsgi_buffer_destroy (ub )
867
868
return ret
868
869
uwsgi .websocket_recv_nb = uwsgi_pypy_websocket_recv_nb
@@ -897,7 +898,7 @@ def uwsgi_pypy_chunked_read(timeout=0):
897
898
chunk = lib .uwsgi_chunked_read (wsgi_req , rlen , timeout , 0 )
898
899
if chunk == ffi .NULL :
899
900
raise IOError ("unable to receive chunked part" )
900
- return ffi .string (chunk , rlen [0 ])
901
+ return ffi .buffer (chunk , rlen [0 ])[:]
901
902
uwsgi .chunked_read = uwsgi_pypy_chunked_read
902
903
903
904
"""
@@ -911,8 +912,7 @@ def uwsgi_pypy_chunked_read_nb():
911
912
if lib .uwsgi_is_again () > 0 :
912
913
return None
913
914
raise IOError ("unable to receive chunked part" )
914
-
915
- return ffi .string (chunk , rlen [0 ])
915
+ return ffi .buffer (chunk , rlen [0 ])[:]
916
916
uwsgi .chunked_read_nb = uwsgi_pypy_chunked_read_nb
917
917
918
918
"""
0 commit comments