[
https://issues.apache.org/jira/browse/ARROW-2036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16345249#comment-16345249
]
ASF GitHub Bot commented on ARROW-2036:
---------------------------------------
jcrist commented on a change in pull request #1517: ARROW-2036: [Python]
Support standard IOBase methods on NativeFile
URL: https://github.com/apache/arrow/pull/1517#discussion_r164782236
##########
File path: python/pyarrow/io.pxi
##########
@@ -65,45 +66,63 @@ cdef class NativeFile:
def __get__(self):
# Emulate built-in file modes
- if self.is_readable and self.is_writeable:
+ if self.is_readable and self.is_writable:
return 'rb+'
elif self.is_readable:
return 'rb'
- elif self.is_writeable:
+ elif self.is_writable:
return 'wb'
else:
raise ValueError('File object is malformed, has no mode')
+ def readable(self):
+ self._assert_open()
+ return self.is_readable
+
+ def writable(self):
+ self._assert_open()
+ return self.is_writable
+
+ def seekable(self):
+ self._assert_open()
+ return self.is_readable
+
def close(self):
- if self.is_open:
+ if not self.closed:
with nogil:
Review comment:
That'd work, but prevents calling `close` again in the case of a failure.
It's not actually clear to me what should happen if `close` fails (reset
state?, set closed anayway?). Anyway, should probably open a jira about this,
as it's unrelated to this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> NativeFile should support standard IOBase methods
> -------------------------------------------------
>
> Key: ARROW-2036
> URL: https://issues.apache.org/jira/browse/ARROW-2036
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Reporter: Jim Crist
> Priority: Minor
> Labels: pull-request-available
>
> If `NativeFile` supported most/all of the standard IOBase methods
> ([https://docs.python.org/3/library/io.html#io.IOBase),] then it'd be easier
> to use arrow files with other python libraries. Would at least be nice to
> support enough operations to use `io.TextIOWrapper`.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)