New submission from Adrien <delgan...@gmail.com>: 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) with gzip.open(output_path, 'wb') as f_out: with open(input_path, 'rb') as f_in: shutil.copyfileobj(f_in, f_out) Although the content can be read correctly using `gzip.open(outputh_path, 'rb')`, it cannot be correctly opened using software like 7-Zip or WinRar. If I open the "test.txt.gzip" file, it contains another "test.txt.gzip" file. If I change the code to use ".gz" extension and then open "test.txt.gz", it contains the expected "test.txt" file. The contained "test.txt.gzip" is actually the same (at bytes level) that "test.txt", just the filename differs which causes tools like 7-Zip to mess up. The bug is not present using compressions functions from "bz2" and "lzma" modules. I can use custom extension, it still can be (un)compressed without issue. As to why I need to use an extension differents from ".gz": I would like to compress arbitrary ".tar" file given in input to ".tgz". I wish the user could open the file in his favorite software archiver and see that it contains a ".tar" file, rather than he does not understand why it contains the same ".tgz" file. ---------- components: Library (Lib) files: test.py messages: 310978 nosy: Delgan priority: normal severity: normal status: open title: Improper gzip compression if output file extension is not "gz" type: behavior versions: Python 3.6 Added file: https://bugs.python.org/file47414/test.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32698> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com