ducktype the array_interface obj to see if it provides tobytes or tostring

This commit is contained in:
wiredfool 2013-05-21 21:04:22 -07:00
parent c3d6b05d10
commit 587b9a79d8

View File

@ -1944,7 +1944,10 @@ def fromarray(obj, mode=None):
size = shape[1], shape[0]
if strides is not None:
obj = obj.tostring()
if hasattr(obj, 'tobytes'):
obj = obj.tobytes()
else:
obj = obj.tostring()
return frombuffer(mode, size, obj, "raw", rawmode, 0, 1)