You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_logging: rotation tests fails on Windows, macOS and FreeBSD #150960
FAIL: test_rollover_based_on_st_birthtime_only (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_based_on_st_birthtime_only)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/buildbot/buildarea/pull_request.itamaro-macos-arm64-aws.macos-with-brew.refleak.nogil/build/Lib/test/test_logging.py", line 6666, in test_rollover_based_on_st_birthtime_only
self.assertTrue(found, msg=msg)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
AssertionError: False is not true : No rotated files found, went back 5 seconds
Example on Windows:
FAIL: test_rollover_based_on_st_birthtime_only (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_based_on_st_birthtime_only)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\bbarea\pull_request.itamaro-win64-srv-22-aws.tailcall.pgo\build\Lib\test\test_logging.py", line 6666, in test_rollover_based_on_st_birthtime_only
self.assertTrue(found, msg=msg)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
AssertionError: False is not true : No rotated files found, went back 5 seconds
Stdout:
Contents of test_logging-2-njcaf5hh.log:
os.stat_result(st_mode=33206, st_ino=116249165381905831, st_dev=5772745545947373322, st_nlink=1, st_uid=0, st_gid=0, st_size=88, st_atime=1780658874, st_mtime=1780658874, st_ctime=1780658869)
2026-06-05 11:27:54,029 testing - new record supposedly in the new file after rollover
Contents of test_logging-2-njcaf5hh.log.2026-06-05_11-27-49:
os.stat_result(st_mode=33206, st_ino=167477611143228771, st_dev=5772745545947373322, st_nlink=1, st_uid=0, st_gid=0, st_size=123, st_atime=1780658871, st_mtime=1780658871, st_ctime=1780658869)
2026-06-05 11:27:49,817 testing - initial
2026-06-05 11:27:51,921 testing - update before rollover to renew the st_mtime
Stderr:
Test time: 2026-06-05 11-27-54
The only matching files are: ['test_logging-2-njcaf5hh.log', 'test_logging-2-njcaf5hh.log.2026-06-05_11-27-49']
It seems like the test_logging regression was introduced by the change commit ac3694b:
commit ac3694b008e4f9d5d5ea6ff8584078f92f6906ab
Author: Ivan Marton <github@martonivan.hu>
Date: Thu Jun 4 15:50:33 2026 +0200
gh-84649: Make TimedRotatingFileHandler use CTIME instead of MTIME (GH-24660)
The TimedRotatingFileHandler previously only used st_mtime attribute of the
log file to detect whether it has to be rotate yet or not. In cases when the
file is changed within the rotatation period the st_mtime is also updated
to the current time and the rotation never happens.
It's more appropriate to check the file creation time (st_ctime) instead.
Whenever available, the more appropriate st_birthtime will be in use. (This
feature is available on FreeBSD, MacOS and Windows at the moment.) If
the st_mtime would be newer than st_ctime (e.g.: because the inode
related to the file has been changed without any file content
modification), then the earliest attribute will be used.
The test fails randomly. python -m test -v test_logging -m test_rollover_based_on_st_birthtime_only -F can be used to reproduce the bug (it may take a few iterations before hitting the bug).
#150954 fixes it. Before it, the test failed after 5-10 iterations, with it, it did not fail after more than a hundred.
I confirm that I fail to reproduce the issue after 1000 iterations of python -m test -v test_logging -m test_rollover_based_on_st_birthtime_only -F on Windows and FreeBSD.
Activity
sergey-miryanov commentedon Jun 5, 2026
@serhiy-storchaka working on this too #84649 (comment)
vstinner commentedon Jun 5, 2026
It seems like the test_logging regression was introduced by the change commit ac3694b:
vstinner commentedon Jun 5, 2026
The test fails randomly.
python -m test -v test_logging -m test_rollover_based_on_st_birthtime_only -Fcan be used to reproduce the bug (it may take a few iterations before hitting the bug).serhiy-storchaka commentedon Jun 5, 2026
#150954 fixes it. Before it, the test failed after 5-10 iterations, with it, it did not fail after more than a hundred.
vstinner commentedon Jun 5, 2026
I confirm that I fail to reproduce the issue after 1000 iterations of
python -m test -v test_logging -m test_rollover_based_on_st_birthtime_only -Fon Windows and FreeBSD.