[issue44262] tarfile: some content different output

Filipe Laíns report at bugs.python.org
Sat May 29 19:39:00 EDT 2021


Filipe Laíns <lains at riseup.net> added the comment:

I modified the script to keep the both Python generated tarballs and ran diffoscope, which presents the issue very clearly:


$ diffoscope py.gz py2.gz
--- py.gz
+++ py2.gz
├── filetype from file(1)
│ @@ -1 +1 @@
│ -gzip compressed data, was "py", last modified: Sat May 29 23:24:02 2021, max compression
│ +gzip compressed data, was "py2", last modified: Sat May 29 23:24:03 2021, max compression


The issue is that by default, when writing gzip files, the mtime will be set for the last modification. This is helpful, but might be unwanted in some cases. You can change the mtime as shown in [1].

Now let's take a look at the difference between the file Python generated and the one the `tar` command generated.


$ diffoscope py.gz tar_a0.tgz
--- py.gz
+++ tar_a0.tgz
├── filetype from file(1)
│ @@ -1 +1 @@
│ -gzip compressed data, was "py", last modified: Sat May 29 23:24:02 2021, max compression
│ +gzip compressed data, from Unix


It seems like it generates the same output here because the `tar` command does not set any mtime on the archive by default.


[1] https://github.com/FFY00/trampolim/blob/dbd03c90eaa2cc732e1a01268786b491dc872fb7/trampolim/_build.py#L354

----------
nosy: +FFY00

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44262>
_______________________________________


More information about the Python-bugs-list mailing list