Closed pepeperezperez closed 5 years ago
Hi, thanks for the bug report.
I think that the file does get closed when s
goes out of scope. Not sure to be honest without writing some code. So I believe the warning is just that and won't adversely affect things.
The real solution might be to implement __enter__
and __exit__
and allow the user to write with ConstBitStream(filename='file.txt') as s:
to guarantee clean-up at a predictable time...
Great, thanks! Using it with context manager would be great!
I believe this is now fixed in the 3.1 update branch (and shortly master too).
Hi!
if I call:
s = bitstring.ConstBitStream(filename='file.txt')
And I return after doing a
s.find()
, it seems like the file.txt is not getting closed. And I'm getting a ResourceWarning for unclosed file.Maybe a call to
source.close()
in the_setfile()
method of Bits.