Adrien added the comment:
Thanks @martin.panter for your response.
I will close this issue as "not a bug" as there is a workaround and as the
current behavior could be deduced by reading carefully the entire documentation.
--
resolution: -> not a bug
stage: -> resolved
status: open
Martin Panter 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')
New submission from Adrien :
Hello.
The following code produces a improper compressed "test.txt.gzip" file:
import gzip
import shutil
input_path = "test.txt"
output_path = input_path + ".gzip"
with open(input_path, 'w') as file:
file.write("abc" * 10)