Test the size() method and fix bug with missing whence

Change-Id: I2ef9faca323f333e7f828d757d8740d20e5e467a
This commit is contained in:
Wes McKinney committed 2016-10-02 20:03:09 -04:00
1 parent 6481e91b2e
commit e9b8c60441
3 files changed
+10 -4

No files matched your search

+8 -2
View File
@@ -48,10 +48,13 @@ def test_python_file_write():
def test_python_file_read():
buf = BytesIO(b'some sample data')
data = b'some sample data'
buf = BytesIO(data)
f = io.PythonFileInterface(buf, mode='r')
assert f.size() == len(data)
assert f.tell() == 0
assert f.read(4) == b'some'
@@ -70,10 +73,13 @@ def test_python_file_read():
def test_bytes_reader():
# Like a BytesIO, but zero-copy underneath for C++ consumers
f = io.BytesReader(b'some sample data')
data = b'some sample data'
f = io.BytesReader(data)
assert f.tell() == 0
assert f.size() == len(data)
assert f.read(4) == b'some'
assert f.tell() == 4
+1 -1
View File
@@ -133,7 +133,7 @@ class PYARROW_EXPORT NumPyBuffer : public arrow::Buffer {
class PYARROW_EXPORT PyBytesBuffer : public arrow::Buffer {
public:
PyBytesBuffer(PyObject* obj);
virtual ~PyBytesBuffer();
~PyBytesBuffer();
private:
PyObject* obj_;
+1 -1
View File
@@ -66,7 +66,7 @@ arrow::Status PythonFile::Close() {
arrow::Status PythonFile::Seek(int64_t position, int whence) {
// whence: 0 for relative to start of file, 2 for end of file
PyObject* result = PyObject_CallMethod(file_, "seek", "(i)", position);
PyObject* result = PyObject_CallMethod(file_, "seek", "(ii)", position, whence);
Py_XDECREF(result);
ARROW_RETURN_NOT_OK(CheckPyError());
return arrow::Status::OK();