Closed djhoese closed 7 years ago
This is great and makes sense to me! I don't see any issues with it, having called close() one should only expect that it's not possible to do anything on the file anymore.
A possible extension of this would be to do the same for the Writer class, and implement __enter__
and __exit__
to allow with
statements.
Thanks!
Some testing frameworks and other utilities will print a warning when files are left open at the end of a test. I've added a
close
method to theReader
class that closes any files that may have been opened. Thisclose
method is also called from__del__
if theReader
object is deleted/garbage collected. The warning I was getting is:I'm not super familiar with the internals of
Reader
so there could be a chance that this could break anything returned by theReader
that referencesshp
,shx
, anddbf
files and depends on them staying open.