@@ -2511,11 +2511,10 @@ def test_isatty(self):
25112511 @unittest .skipUnless (hasattr (os , 'closerange' ), 'test needs os.closerange()' )
25122512 def test_closerange (self ):
25132513 if support .is_mac_catalyst :
2514- # On Mac Catalyst, somehow we're not detecting a guarded FD
2515- # using fstat. We make some random fds first, stop once not
2516- # consecutive, close all of them one by one using the result
2517- # of open(), then assert that closerange is failing.
2518- #
2514+ # On Mac Catalyst, somehow there's a guarded FD in the way,
2515+ # undected using fstat. We make some random fds first, stop
2516+ # once not consecutive, close all of them one by one using
2517+ # the result of open(), then assert that closerange is failing.
25192518 # This ensures that none of those things we're closing is
25202519 # guarded, if we're careful to not use code that makes guarded
25212520 # file descriptors.
@@ -2525,13 +2524,16 @@ def test_closerange(self):
25252524 file = open (os_helper .TESTFN , "wb" )
25262525 fd = file .fileno ()
25272526 copies .append (file )
2528- for i in range (10 ):
2527+ for i in range (1 , 10 ):
25292528 file_dup = open (os_helper .TESTFN , "wb" )
25302529 if file_dup .fileno () != fd + i :
25312530 file_dup .close ()
25322531 break
25332532 else :
25342533 copies .append (file_dup )
2534+ if i < 2 :
2535+ raise unittest .SkipTest (
2536+ "Unable to acquire a range of invalid file descriptors" )
25352537 # Close everything
25362538 for copy in copies :
25372539 copy .close ()
0 commit comments