Skip to content

Commit

Permalink
pythongh-95675 fix uid and gid at test_add_dir_getmember
Browse files Browse the repository at this point in the history
  • Loading branch information
uyw4687 committed Feb 24, 2023
1 parent 7c106a4 commit f9deb31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,17 @@ 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."
)
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:
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ Jon Oberheide
Milan Oberkirch
Pascal Oberndoerfer
Géry Ogam
Seonkyo Ok
Jeffrey Ollie
Adam Olsen
Bryan Olson
Expand Down

0 comments on commit f9deb31

Please sign in to comment.