File reproducible.patch of Package python311

commit 44ba7cf517f39b7a37a216134f83aef0c156ed85
Author: Bernhard M. Wiedemann <bwiedemann@suse.de>
Date:   Mon Jan 29 12:44:51 2024 +0100

    Sort os.listdir output
    
    See https://reproducible-builds.org/ for why this is good.
    
    This patch was done while working on reproducible builds for openSUSE.

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e70fef5ebf..cc6f34fdcf 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4259,6 +4259,11 @@ _posix_listdir(path_t *path, PyObject *list)
         Py_END_ALLOW_THREADS
     }
 
+    if(list)
+        if(PyList_Sort(list)) {
+            Py_DECREF(list);
+            return NULL;
+        }
     return list;
 }  /* end of _posix_listdir */
 #endif  /* which OS */

commit dc2c98364355da5d3524c8b801c1adaea9861e89
Author: Bernhard M. Wiedemann <bwiedemann@suse.de>
Date:   Mon Jan 29 12:47:02 2024 +0100

    Sort glob output
    
    Similar to C, bash, perl, ruby, make
    
    See https://reproducible-builds.org/ for why this is good.
    
    This patch was done while working on reproducible builds for openSUSE.

diff --git a/Lib/glob.py b/Lib/glob.py
index a7256422d5..97b76f0b67 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -25,7 +25,7 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
     If `recursive` is true, the pattern '**' will match any files and
     zero or more directories and subdirectories.
     """
-    return list(iglob(pathname, root_dir=root_dir, dir_fd=dir_fd, recursive=recursive,
+    return sorted(iglob(pathname, root_dir=root_dir, dir_fd=dir_fd, recursive=recursive,
                       include_hidden=include_hidden))
 
 def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,

commit 2187351a2365e1a06944bf2f34bdc3f4fd97f73b
Author: Bernhard M. Wiedemann <bwiedemann@suse.de>
Date:   Mon Jan 29 12:43:42 2024 +0100

    Process os.walk deterministically
    
    We sort to negate the unpredictable filesystem readdir order.
    
    See https://reproducible-builds.org/ for why this is good.
    
    This patch was done while working on reproducible builds for openSUSE.

diff --git a/Lib/os.py b/Lib/os.py
index fd1e774fdc..c8f4c37673 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -403,6 +403,8 @@ def _walk(top, topdown, onerror, followlinks):
                 if walk_into:
                     walk_dirs.append(entry.path)
 
+    dirs.sort()
+    nondirs.sort()
     # Yield before recursion if going top down
     if topdown:
         yield top, dirs, nondirs
@@ -419,7 +421,7 @@ def _walk(top, topdown, onerror, followlinks):
                 yield from _walk(new_path, topdown, onerror, followlinks)
     else:
         # Recurse into sub-directories
-        for new_path in walk_dirs:
+        for new_path in sorted(walk_dirs):
             yield from _walk(new_path, topdown, onerror, followlinks)
         # Yield after recursion if going bottom up
         yield top, dirs, nondirs
openSUSE Build Service is sponsored by