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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.7
    • Affects Version/s: 2.6.3
    • Component/s: None
    • Environment:
      Python 3.3.3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Kyle Erf (Inactive)
            Reporter:
            Jimmy Mabey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: