You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Antoine Pitrou (JIRA)" <ji...@apache.org> on 2018/09/12 19:13:00 UTC

[jira] [Created] (ARROW-3227) [Python] NativeFile.write shouldn't accept unicode strings

Antoine Pitrou created ARROW-3227:
-------------------------------------

             Summary: [Python] NativeFile.write shouldn't accept unicode strings
                 Key: ARROW-3227
                 URL: https://issues.apache.org/jira/browse/ARROW-3227
             Project: Apache Arrow
          Issue Type: Bug
          Components: Python
    Affects Versions: 0.10.0
            Reporter: Antoine Pitrou


Arrow files are binary, but for some reason {{NativeFile.write}} silently converts unicode strings to bytes.
{code:python}
>>> b = io.BytesIO()
>>> b.write("foo")
Traceback (most recent call last):
  File "<ipython-input-6-a7195dbc0372>", line 1, in <module>
    b.write("foo")

TypeError: a bytes-like object is required, not 'str'
>>> f = pa.PythonFile(b)
>>> f.write("foo")
>>> b.getvalue()
b'foo'
>>> f.write("😀")
>>> b.getvalue()
b'foo\xf0\x9f\x98\x80'
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)