Skip to content

Commit

Permalink
[3.11] gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#10…
Browse files Browse the repository at this point in the history
…9697) (#109699)

gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#109697)

On FreeBSD, regular users cannot set the sticky bit. Skip the test if
chmod() fails with EFTYPE error.

(cherry picked from commit 26e06ad)
  • Loading branch information
vstinner authored Sep 21, 2023
1 parent b3af888 commit 3a6d8e6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import errno
import sys
import os
import io
Expand Down Expand Up @@ -3723,9 +3724,21 @@ def test_modes(self):
tmp_filename = os.path.join(TEMPDIR, "tmp.file")
with open(tmp_filename, 'w'):
pass
os.chmod(tmp_filename, os.stat(tmp_filename).st_mode | stat.S_ISVTX)
have_sticky_files = (os.stat(tmp_filename).st_mode & stat.S_ISVTX)
os.unlink(tmp_filename)
try:
try:
os.chmod(tmp_filename,
os.stat(tmp_filename).st_mode | stat.S_ISVTX)
except OSError as exc:
if exc.errno == getattr(errno, "EFTYPE", 0):
# gh-108948: On FreeBSD, regular users cannot set
# the sticky bit.
self.skipTest("chmod() failed with EFTYPE: "
"regular users cannot set sticky bit")
else:
raise
have_sticky_files = (os.stat(tmp_filename).st_mode & stat.S_ISVTX)
finally:
os.unlink(tmp_filename)

os.mkdir(tmp_filename)
os.chmod(tmp_filename, os.stat(tmp_filename).st_mode | stat.S_ISVTX)
Expand Down

0 comments on commit 3a6d8e6

Please sign in to comment.