diff options
author | Prashanth Pai <ppai@redhat.com> | 2015-06-17 12:46:58 +0530 |
---|---|---|
committer | Thiago da Silva <thiago@redhat.com> | 2015-06-18 05:53:54 -0700 |
commit | 2c468ae0d5a1e25998373abb72d87b1ee7693816 (patch) | |
tree | 3befca1e0e8ae2dfd6fac36e876ca06948724840 /test/unit/gluster | |
parent | ddbd7b570d0a9f599b417a499c912c5b13a003c9 (diff) |
Fix reading of binary data in read()
As per the current code, this is the behavior:
>>> with v.fopen("/abc", 'r') as f:
... data = f.read(5)
>>> print data
<ctypes.c_char_Array_2 object at 0x7fda7d6bbb90>
>>> print data.value
hello
>>>
It's incorrect to return a ctypes internal object back to the user.
In Python 2.x, read() always returns a string. It's really upto
the consumer to decode this string into whatever encoding it was
written with.
This patch reverts parts of this old change:
Ia2bb47343880cbf7121fed9510e4cfa085fe23bd
Change-Id: Ia1d3e5834be2b856776bd3cf8382a17ffd61d5df
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'test/unit/gluster')
-rw-r--r-- | test/unit/gluster/test_gfapi.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index 1463f76..f850f0f 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -163,7 +163,7 @@ class TestFile(unittest.TestCase): with patch("gluster.gfapi.api.glfs_read", _mock_glfs_read): b = self.fd.read(5) - self.assertEqual(b.value, "hello") + self.assertEqual(b, "hello") def test_read_fail_exception(self): mock_glfs_read = Mock() |