File python-sorted_tar.patch of Package python.14931

commit 6936e36efcc0a75c7d5e67b949c9749d61fa5ead
Author: Bernhard M. Wiedemann <>
Date:   Sun Jun 18 03:50:25 2017 +0200

    tarfile: sort directory listing
    to generate tar files in a more reproducible way

diff --git a/Lib/ b/Lib/
index adf91d5382..36f6ed7167 100644
--- a/Lib/
+++ b/Lib/
@@ -2027,7 +2027,7 @@ class TarFile(object):
         elif tarinfo.isdir():
             if recursive:
-                for f in os.listdir(name):
+                for f in sorted(os.listdir(name)):
                     self.add(os.path.join(name, f), os.path.join(arcname, f),
                             recursive, exclude, filter)