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

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

     [ https://issues.apache.org/jira/browse/ARROW-3227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes McKinney reassigned ARROW-3227:
-----------------------------------

    Assignee: Wes McKinney

> [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
>            Assignee: Wes McKinney
>            Priority: Major
>             Fix For: 0.11.0
>
>
> 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)