geopandas / pyogrio

Vectorized vector I/O using OGR
https://pyogrio.readthedocs.io
MIT License
276 stars 24 forks source link

Always seek to beginning of readable file before reading, and raise error if no bytes can be read #492

Open brendan-ward opened 3 weeks ago

brendan-ward commented 3 weeks ago

Per read-related issues raised in GeoPandas #3379.

If user writes to an open file (perhaps an in-memory temporary file) but does not reset the read pointer via seek to the beginning of the file, we attempt to read from the end of the file, read no bytes into the in-memory file we create, and then GDAL raises a confusing error because the input file in the in-memory file is not valid.

If the file is seekable, we should be able to seek to the beginning. Then, we can raise an error if there were no bytes read.