[issue32698] Improper gzip compression if output file extension is not "gz"
Martin Panter
report at bugs.python.org
Sun Jan 28 17:27:15 EST 2018
Martin Panter <vadmium+py at gmail.com> added the comment:
According to the documentation, you can use the lower-level GzipFile constructor’s “filename” argument:
>>> with open(output_path, 'wb') as f_out, \
... gzip.GzipFile(fileobj=f_out, mode='wb', filename=input_path) as f_out, \
... open(input_path, 'rb') as f_in:
... shutil.copyfileobj(f_in, f_out)
...
>>> import os
>>> os.system("7z l test.txt.gzip")
[. . .]
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2018-01-28 22:23:16 ..... 30 34 test.txt
------------------- ----- ------------ ------------ ------------------------
----------
nosy: +martin.panter
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32698>
_______________________________________
More information about the Python-bugs-list
mailing list