File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change
1
+ import errno
1
2
import sys
2
3
import os
3
4
import io
@@ -3791,9 +3792,21 @@ def test_modes(self):
3791
3792
tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3792
3793
with open (tmp_filename , 'w' ):
3793
3794
pass
3794
- os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3795
- have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3796
- os .unlink (tmp_filename )
3795
+ try :
3796
+ try :
3797
+ os .chmod (tmp_filename ,
3798
+ os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3799
+ except OSError as exc :
3800
+ if exc .errno == getattr (errno , "EFTYPE" , 0 ):
3801
+ # gh-108948: On FreeBSD, regular users cannot set
3802
+ # the sticky bit.
3803
+ self .skipTest ("chmod() failed with EFTYPE: "
3804
+ "regular users cannot set sticky bit" )
3805
+ else :
3806
+ raise
3807
+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3808
+ finally :
3809
+ os .unlink (tmp_filename )
3797
3810
3798
3811
os .mkdir (tmp_filename )
3799
3812
os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
You can’t perform that action at this time.
0 commit comments