Hi, thank you for the awesome project, it has recently been very useful to me and still works great at reading these old files. I think projects like these are very important.
There is one small fix I would like to ask for.
Running the most basic example:
import compoundfiles
with compoundfiles.CompoundFileReader("foo.txm") as doc:
entry = doc.root[0]
if entry.isfile:
with doc.open(entry) as stream:
print(len(stream.read()))
with a recent Python (I have 3.13), will read the data correctly but a warning will be printed:
Exception ignored in: <compoundfiles.streams.CompoundFileMiniStream object at 0x719e7de27280>
Traceback (most recent call last):
File "/proj/.venv/lib/python3.13/site-packages/compoundfiles/streams.py", line 245, in close
AttributeError: 'NoneType' object has no attribute 'close'
I believe this is because the CompoundFileMiniStream.close function is being called twice
Here is a minimal example which reproduces the issue:
import io
class MyTestClass(io.RawIOBase):
def __init__(self):
print("MyTestClass.__init__")
def close(self):
print("MyTestClass.close")
with MyTestClass() as d:
print("inside")
which will print out:
MyTestClass.__init__
inside
MyTestClass.close
MyTestClass.close
I believe the smallest fix it to also call the close() method in the base implementation, i.e.
import io
class MyTestClass(io.RawIOBase):
def __init__(self):
print("MyTestClass.__init__")
def close(self):
super().close() # this is the fix
print("MyTestClass.close")
with MyTestClass() as d:
print("inside")
So, my suggestion would be to change the CompoundFileMiniStream.close function to:
def close(self):
super().close() # add this line
try:
self._file.close()
finally:
self._file = None
Hi, thank you for the awesome project, it has recently been very useful to me and still works great at reading these old files. I think projects like these are very important.
There is one small fix I would like to ask for.
Running the most basic example:
with a recent Python (I have 3.13), will read the data correctly but a warning will be printed:
I believe this is because the
CompoundFileMiniStream.closefunction is being called twicecompoundfiles/compoundfiles/streams.py
Line 243 in cc617cd
Here is a minimal example which reproduces the issue:
which will print out:
I believe the smallest fix it to also call the
close()method in the base implementation, i.e.So, my suggestion would be to change the
CompoundFileMiniStream.closefunction to: