bauman / python-idzip

Seekable, gzip compatible, compression format
MIT License
15 stars 12 forks source link

TypeError: `output` must be a file-like object supporting write, tell, flush, and close! #5

Closed codito closed 6 years ago

codito commented 6 years ago

python-idzip version 0.3

Sample code to reproduce the issue

import idzip

with open("/tmp/r.txt", mode="wb") as f:
    zipfile = idzip.IdzipFile(fileobj=f, mode="wb")
    zipfile.write(b"\x00ed")
    zipfile.close()

Stacktrace

Traceback (most recent call last):
  File "/tmp/trial.py", line 4, in <module>
    zipfile = idzip.IdzipFile(fileobj=f, mode="wb")
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/api.py", line 39, in __init__                                                       
    self._impl = self._make_writer(fileobj, sync_size=sync_size, mtime=mtime)
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/api.py", line 53, in _make_writer                                                   
    return IdzipWriter(filespec, sync_size=sync_size, mtime=mtime)
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/compressor.py", line 266, in __init__                                               
    "`output` must be a file-like object supporting "
TypeError: `output` must be a file-like object supporting write, tell, flush, and close!                                                                       
Exception ignored in: <bound method IOStreamWrapperMixin.__del__ of <idzip.compressor.IdzipWriter object at 0x7f6039c2d4a8>>                                   
Traceback (most recent call last):
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/_stream.py", line 22, in __del__                                                    
    if not self.closed:
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/_stream.py", line 7, in closed                                                      
    return self.stream.closed
  File "/home/arun/src/gh/stardict/.venv/lib/python3.6/site-packages/idzip/compressor.py", line 293, in stream                                                 
    return self.output
AttributeError: 'IdzipWriter' object has no attribute 'output'
bauman commented 6 years ago

thank you