[Python-checkins] [3.10] gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207) (gh-102230)

corona10 webhook-mailer at python.org
Fri Feb 24 21:56:14 EST 2023


https://github.com/python/cpython/commit/3e80d21b7673edf70753e14d88907c60bc6970c3
commit: 3e80d21b7673edf70753e14d88907c60bc6970c3
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: corona10 <donghee.na92 at gmail.com>
date: 2023-02-25T11:56:08+09:00
summary:

[3.10] gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207) (gh-102230)

gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207)
(cherry picked from commit 56e93c8020e89e1712aa238574bca2076a225028)

Co-authored-by: Seonkyo Ok <seonkyo.ok at linecorp.com>

files:
M Lib/test/test_tarfile.py
M Misc/ACKS

diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index cba95e9320ec..89f5a561b4aa 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -225,18 +225,19 @@ def test_add_dir_getmember(self):
         self.add_dir_and_getmember('bar')
         self.add_dir_and_getmember('a'*101)
 
-    @unittest.skipIf(
-        (hasattr(os, 'getuid') and os.getuid() > 0o777_7777) or
-        (hasattr(os, 'getgid') and os.getgid() > 0o777_7777),
-        "uid or gid too high for USTAR format."
-    )
+    @unittest.skipUnless(hasattr(os, "getuid") and hasattr(os, "getgid"),
+                         "Missing getuid or getgid implementation")
     def add_dir_and_getmember(self, name):
+        def filter(tarinfo):
+            tarinfo.uid = tarinfo.gid = 100
+            return tarinfo
+
         with os_helper.temp_cwd():
             with tarfile.open(tmpname, 'w') as tar:
                 tar.format = tarfile.USTAR_FORMAT
                 try:
                     os.mkdir(name)
-                    tar.add(name)
+                    tar.add(name, filter=filter)
                 finally:
                     os.rmdir(name)
             with tarfile.open(tmpname) as tar:
diff --git a/Misc/ACKS b/Misc/ACKS
index 10a35fd64abf..b4be8af3d99f 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1286,6 +1286,7 @@ Jon Oberheide
 Milan Oberkirch
 Pascal Oberndoerfer
 Géry Ogam
+Seonkyo Ok
 Jeffrey Ollie
 Adam Olsen
 Bryan Olson



More information about the Python-checkins mailing list