Skip to content

Commit a80b517

Browse files
committed
Merge pull request mongodb#222 from 3rf/PYTHON-621
PYTHON-621: Fixed GridOut.read(0) returning string in Python 3
2 parents 911cf71 + 464941e commit a80b517

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

gridfs/grid_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def read(self, size=-1):
468468
self._ensure_file()
469469

470470
if size == 0:
471-
return ""
471+
return EMPTY
472472

473473
remainder = int(self.length) - self.__position
474474
if size < 0 or size > remainder:

test/test_grid_file.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def test_basic(self):
7474
g = GridOut(self.db.fs, f._id)
7575
self.assertEqual(b(""), g.read())
7676

77+
# test that reading 0 returns proper type
78+
self.assertEqual(b(""), g.read(0))
79+
7780
def test_md5(self):
7881
f = GridIn(self.db.fs)
7982
f.write(b("hello world\n"))

0 commit comments

Comments
 (0)