diff --git a/test/test_filelike.py b/test/test_filelike.py index beff7d626..98bb02370 100644 --- a/test/test_filelike.py +++ b/test/test_filelike.py @@ -90,6 +90,15 @@ class TestLimitingStream(unittest.TestCase): class TestStreamSlice(unittest.TestCase): + def test_none_read(self): + class NoneReader(object): + def read(self, size=None): + return None + + stream = StreamSlice(NoneReader(), 0) + self.assertEquals(None, stream.read(-1)) + self.assertEquals(0, stream.tell()) + def test_noslice(self): fileobj = StringIO('this is a cool test') stream = StreamSlice(fileobj, 0) @@ -123,4 +132,4 @@ class TestStreamSlice(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/util/registry/filelike.py b/util/registry/filelike.py index 0ace55adc..97555a23f 100644 --- a/util/registry/filelike.py +++ b/util/registry/filelike.py @@ -15,6 +15,8 @@ class BaseStreamFilelike(object): def read(self, size=READ_UNTIL_END): buf = self._fileobj.read(size) + if buf is None: + return None self._cursor_position += len(buf) return buf