Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Opening file object in append mode fail. #1027

Closed
RemiDesgrange opened this issue Jul 27, 2021 · 2 comments
Closed

Opening file object in append mode fail. #1027

RemiDesgrange opened this issue Jul 27, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@RemiDesgrange
Copy link

RemiDesgrange commented Jul 27, 2021

Expected behavior and actual behavior.

Opening a file-descriptor (BytesIO, StringIO, or an openned file doesn't work with the append mode.

This is normal see implementation here: https://github.com/Toblerity/Fiona/blob/master/fiona/__init__.py#L212 and https://github.com/Toblerity/Fiona/blob/master/fiona/__init__.py#L212

Steps to reproduce the problem.

import fiona
from io import BytesIO

fp = BytesIO(b"some random valid geopackage bytes")
with fiona.open(fp, 'a', driver="Gpkg", schema={"something": "valid"}) as gpkg_file:
    pass

Operating system

Linux (Arch)

Fiona and GDAL version and provenance

1.8.20 manylinux1 wheel installed from PyPI using pip version 21.1.3.

GDAL 3.3, installed via package manager.

@jsta
Copy link

jsta commented Aug 19, 2021

I'm seeing an error message:

with fiona.open(fp, 'a', driver="Gpkg", schema={"something": "valid"}) as gpkg_file:
  File "/home/jsta/.conda/envs/vote/lib/python3.8/site-packages/fiona/env.py", line 417, in wrapper
    return f(*args, **kwargs)
  File "/home/jsta/.conda/envs/vote/lib/python3.8/site-packages/fiona/__init__.py", line 253, in open
    path = parse_path(fp)
  File "/home/jsta/.conda/envs/vote/lib/python3.8/site-packages/fiona/path.py", line 132, in parse_path
    elif path.startswith('/vsi'):
AttributeError: '_io.BytesIO' object has no attribute 'startswith

@sgillies
Copy link
Member

sgillies commented Feb 1, 2022

@jsta we only support read-only and write-only access to datasets in a Python file object. I'm making this more clear in 55d039e.

@sgillies sgillies added this to the 1.8.21 milestone Feb 1, 2022
@sgillies sgillies added bug and removed bug labels Feb 1, 2022
@sgillies sgillies self-assigned this Feb 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants