Closed
Description
PyShp Version
2.3.0
Python Version
3.10
Your code
shpio = BytesIO()
shxio = BytesIO()
dbfio = BytesIO()
with shapefile.Writer(shx=shxio, dbf=dbfio, shp=shpio) as shp:
...
zio = BytesIO()
with zipfile.ZipFile(
zio, mode="w", compression=zipfile.ZIP_DEFLATED
) as zf:
zf.writestr("fn.shp", shpio.getvalue())
zf.writestr("fn.shx", shxio.getvalue())
zf.writestr("fn.dbf", dbfio.getvalue())
Full stacktrace
zf.writestr("fn.shp", shpio.getvalue())
ValueError: I/O operation on closed file.
Other notes
af1dee9 appears to now close any file objects. Perhaps my usage is not a best practice for BytesIO objects, but even in a context manager, the new pyshp code will close the bytesio objects.