Skip to content
Snippets Groups Projects
Commit 4a5eec24 authored by Yichao Yu's avatar Yichao Yu
Browse files

c_buffer_from_obj for bytes

parent bae2c48a
No related branches found
No related tags found
No related merge requests found
......@@ -453,7 +453,7 @@ def _c_buffer_from_obj(obj, writable=False):
obj.__array_interface__['data'][0]),
obj.nbytes,
None)
if isinstance(obj, np.generic):
elif isinstance(obj, np.generic):
# numpy scalar
#
# * obj.__array_interface__ exists in CPython, but the address does
......@@ -467,6 +467,10 @@ def _c_buffer_from_obj(obj, writable=False):
s_array.__array_interface__['data'][0]),
s_array.nbytes,
s_array)
elif isinstance(obj, bytes):
# There sould be better ways to pass arguments
p = _ffi.new('char[]', obj)
return (_ffi.cast('void *', p), len(obj), p)
else:
raise LogicError("", status_code.INVALID_VALUE,
"PyOpencl on PyPy only accepts numpy arrays "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment