@@ -5190,6 +5190,13 @@ def test_should_not_rollover(self):
5190
5190
self .fn , encoding = "utf-8" , maxBytes = 0 )
5191
5191
self .assertFalse (rh .shouldRollover (None ))
5192
5192
rh .close ()
5193
+ # bpo-45401 - test with special file
5194
+ # We set maxBytes to 1 so that rollover would normally happen, except
5195
+ # for the check for regular files
5196
+ rh = logging .handlers .RotatingFileHandler (
5197
+ os .devnull , encoding = "utf-8" , maxBytes = 1 )
5198
+ self .assertFalse (rh .shouldRollover (self .next_rec ()))
5199
+ rh .close ()
5193
5200
5194
5201
def test_should_rollover (self ):
5195
5202
rh = logging .handlers .RotatingFileHandler (self .fn , encoding = "utf-8" , maxBytes = 1 )
@@ -5284,6 +5291,14 @@ def rotator(source, dest):
5284
5291
rh .close ()
5285
5292
5286
5293
class TimedRotatingFileHandlerTest (BaseFileTest ):
5294
+ def test_should_not_rollover (self ):
5295
+ # See bpo-45401. Should only ever rollover regular files
5296
+ fh = logging .handlers .TimedRotatingFileHandler (
5297
+ os .devnull , 'S' , encoding = "utf-8" , backupCount = 1 )
5298
+ time .sleep (1.1 ) # a little over a second ...
5299
+ r = logging .makeLogRecord ({'msg' : 'testing - device file' })
5300
+ self .assertFalse (fh .shouldRollover (r ))
5301
+
5287
5302
# other test methods added below
5288
5303
def test_rollover (self ):
5289
5304
fh = logging .handlers .TimedRotatingFileHandler (
0 commit comments