GeospatialPython/pyshp

Writing to only one shapefile type throwing an error

mem00 opened this issue · 2 comments

mem00 commented

w = shapefile.Writer(shp="/path/tofile.shp")

as per the documentation

w = shapefile.Writer(dbf='shapefiles/test/onlydbf.dbf')
w.field('field1', 'C')

throws

ShapefileException: No file-like object available.

when trying to write a polygon

w.poly(geometry)

I was able to reproduce your error. We did have unit tests for this usecase that created a writer, but the error only happens when trying to add the first shape which we didn't do in the test. Will get this fixed for the next release, though if you're able to submit a PR that will be faster.

Fixed the error and the tests, should be available in next version. Thanks for finding the issue!