Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-3227

[Python] NativeFile.write shouldn't accept unicode strings

    Details

      Description

      Arrow files are binary, but for some reason NativeFile.write silently converts unicode strings to bytes.

      >>> 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'
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                wesmckinn Wes McKinney
                Reporter:
                pitrou Antoine Pitrou
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m