Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
call .close() on shapefile.Writer objects properly. Don't just rely o…
…n del ing them. Fixes fiftysevendegreesofrad#11 File writer objects were being relied on to close themselves. In Iron Python relying on del to call .close() or some other error meant Shapefile headers were not being written properly - this should happen in the __exit__ of the context manager but can be called in .close() if preferred. del is known to result in wierd behaviour in cPython, and it's certainly no better in Iron Python, so ought not be relied on to call .close() The curious number 960051513 that made its way into the shapefile type in the header, is 39393939 in base 16. 39 happens to be b'9'.hex(). In shapefile.Writer.__init__ long before the header is constructed properly (as the length of the file is not yet known) is the following line of code: if self.shp: self.shp.write(b'9'*100) This just reserves the 100 bytes of space required at the start of the file according to the ESRI shapefile spec.
- Loading branch information