amol- commented on a change in pull request #10054:
URL: https://github.com/apache/arrow/pull/10054#discussion_r615844457



##########
File path: python/pyarrow/io.pxi
##########
@@ -1449,6 +1449,10 @@ cdef shared_ptr[CBuffer] as_c_buffer(object o) except *:
 
 
 cdef NativeFile get_native_file(object source, c_bool use_memory_map):
+    if source is None:

Review comment:
       The same issue seems to involved btw also callers of `get_input_stream` 
which is a bit more widespread.
   See for example
   ```
   >>> json.read_json(None)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "pyarrow/_json.pyx", line 238, in pyarrow._json.read_json
       _get_reader(input_file, &stream)
     File "pyarrow/_json.pyx", line 193, in pyarrow._json._get_reader
       get_input_stream(input_file, use_memory_map, out)
     File "pyarrow/io.pxi", line 1494, in pyarrow.lib.get_input_stream
       input_stream = nf.get_input_stream()
   AttributeError: 'NoneType' object has no attribute 'get_input_stream'
   ```
   
   I wonder if a possible strategy might also be to provide an error signaling 
return value to `get_reader` and `get_input_stream` (as they don't return 
anything) and use it for the purpose of adding an `except -1` or something like 
that.
   
   That seems would cover more paths that could all end up in this situation.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to