@@ -57,24 +57,26 @@ def test_fsize_enforced(self):
5757
5858 if max_lim != resource .RLIM_INFINITY and max_lim < 1025 :
5959 self .skipTest (f"system RLIMIT_FSIZE hard limit ({ max_lim } ) is too small for this test" )
60-
6160 try :
62- with open (os_helper .TESTFN , "wb" ) as f :
63- resource .setrlimit (resource .RLIMIT_FSIZE , (1024 , max_lim ))
64-
65- f .write (b"X" * 1024 )
66- # This should raise OSError because it exceeds the 1024 byte limit
67- with self .assertRaises (OSError , msg = "f.write() did not raise OSError when exceeding RLIMIT_FSIZE" ):
68- f .write (b"Y" )
69- f .flush ()
70- # On some systems (e.g., Ubuntu on hppa) the flush()
71- # doesn't always cause the exception, but the close()
72- # does eventually. Try flushing several times in
73- # an attempt to ensure the file is really synced and
74- # the exception raised.
75- for i in range (5 ):
76- time .sleep (.1 )
61+ try :
62+ with open (os_helper .TESTFN , "wb" ) as f :
63+ resource .setrlimit (resource .RLIMIT_FSIZE , (1024 , max_lim ))
64+ f .write (b"X" * 1024 )
65+ with self .assertRaises (OSError , msg = "f.write() did not raise OSError when exceeding RLIMIT_FSIZE" ):
66+ f .write (b"Y" )
7767 f .flush ()
68+ # On some systems (e.g., Ubuntu on hppa) the flush()
69+ # doesn't always cause the exception, but the close()
70+ # does eventually. Try flushing several times in
71+ # an attempt to ensure the file is really synced and
72+ # the exception raised.
73+ for i in range (5 ):
74+ time .sleep (.1 )
75+ f .flush ()
76+ except OSError as e :
77+ if e .errno == errno .EFBIG :
78+ self .skipTest (f"ASAN/OS raised EFBIG prematurely on open/setup: { e } " )
79+ raise
7880 finally :
7981 resource .setrlimit (resource .RLIMIT_FSIZE , (cur , max_lim ))
8082
0 commit comments