@@ -5216,6 +5216,13 @@ def test_should_not_rollover(self):
52165216 self .fn , encoding = "utf-8" , maxBytes = 0 )
52175217 self .assertFalse (rh .shouldRollover (None ))
52185218 rh .close ()
5219+ # bpo-45401 - test with special file
5220+ # We set maxBytes to 1 so that rollover would normally happen, except
5221+ # for the check for regular files
5222+ rh = logging .handlers .RotatingFileHandler (
5223+ os .devnull , encoding = "utf-8" , maxBytes = 1 )
5224+ self .assertFalse (rh .shouldRollover (self .next_rec ()))
5225+ rh .close ()
52195226
52205227 def test_should_rollover (self ):
52215228 rh = logging .handlers .RotatingFileHandler (self .fn , encoding = "utf-8" , maxBytes = 1 )
@@ -5310,6 +5317,14 @@ def rotator(source, dest):
53105317 rh .close ()
53115318
53125319class TimedRotatingFileHandlerTest (BaseFileTest ):
5320+ def test_should_not_rollover (self ):
5321+ # See bpo-45401. Should only ever rollover regular files
5322+ fh = logging .handlers .TimedRotatingFileHandler (
5323+ os .devnull , 'S' , encoding = "utf-8" , backupCount = 1 )
5324+ time .sleep (1.1 ) # a little over a second ...
5325+ r = logging .makeLogRecord ({'msg' : 'testing - device file' })
5326+ self .assertFalse (fh .shouldRollover (r ))
5327+
53135328 # other test methods added below
53145329 def test_rollover (self ):
53155330 fh = logging .handlers .TimedRotatingFileHandler (
0 commit comments