You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
open built-in lets you use write method on any object as long as it implements Buffer Protocol. However, smart_open restricts writeable types to only bytes, bytearray and memoryview. Is there a specific reason behind that? I'm using smart_open to upload to S3 files that are created using pyarrow. PyArrow has a (new?) type called Buffer which implements Buffer Protocol. Therefore, when I try to write it through smart_open, it just crashes while it just works with built-in open function.
I can easily fix the crash by skipping the type check in smart_open which seem to work flawlessly in my case. See #361
Would you be confident with such change? Not sure why the isinstance check was added in the first place. The error thrown by Python is already very explicit:
TypeError: a bytes-like object is required, not 'xxx'
The text was updated successfully, but these errors were encountered:
gilbsgilbs
added a commit
to gilbsgilbs/smart_open
that referenced
this issue
Oct 8, 2019
open
built-in lets you usewrite
method on any object as long as it implements Buffer Protocol. However,smart_open
restricts writeable types to onlybytes
,bytearray
andmemoryview
. Is there a specific reason behind that? I'm usingsmart_open
to upload to S3 files that are created usingpyarrow
. PyArrow has a (new?) type calledBuffer
which implements Buffer Protocol. Therefore, when I try to write it throughsmart_open
, it just crashes while it just works with built-inopen
function.I can easily fix the crash by skipping the type check in
smart_open
which seem to work flawlessly in my case. See #361Would you be confident with such change? Not sure why the
isinstance
check was added in the first place. The error thrown by Python is already very explicit:The text was updated successfully, but these errors were encountered: