Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-621

Python 3: read(0) on a GridOut instance returns a string instead of bytes

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 2.7
    • 2.6.3
    • None
    • Python 3.3.3

    Description

      Calling read(0) on a GridOut instance returns "" instead of b"" in Python 3.

      This is because read() checks for a zero size and always returns "", even though the function should always return bytes in Python 3: https://github.com/mongodb/mongo-python-driver/blob/master/gridfs/grid_file.py#L470

      I'm using a library (html5lib) that uses read(0) to determine if it should expect strings or bytes from the file object. So this inconsistency is leading it into handling the file data as strings when it should be handling it as bytes.

      Attachments

        Activity

          People

            kyle.erf Kyle Erf
            mabeyj Jimmy Mabey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: