tarfile.open(filename, "w|") creates a tar file with execute permissions set, if filename doesn't exist (i.e. it uses mode 0777 minus the umask). It should instead use mode 0666 minus the umask, which is what happens when using mode "w:..." instead of "w
...". AFAICT this bug has always been present since the introduction of tarfile in Python 2.3, but it may soon become more noticeable since the new function shutil.make_archive() in Python 2.7 and 3.2 uses tarfile with mode "w
Is "self.fd = os.open(name, mode, 0666)" Ok ? Should not it be "self.fd = os.open(name, mode, 0644)", because that is what the default permissions are.
I think 0666 is correct because os.open() does a bitwise AND between this value and the bitwise inversion of the umask, something like oct(0666 & ~umask). Since the umask is usually 022 octal (18 decimal), the actual permission on disk should be 0644 as expected.
0666 is the right mode and the patch is correct. @Tarek: Why does shutil.make_archive() use mode "w|..." instead of "w:..."? IMHO that is not necessary, because it works on regular files only.