gh-84649: Use statx() in TimedRotatingFileHandler if available by serhiy-storchaka · Pull Request #150968 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vstinner, could you please look at this? Do I use statx() like it is supposed to be used?
| @unittest.skipUnless(hasattr(os.stat_result, 'st_birthtime') or | ||
| support.has_st_birthtime or hasattr(os, 'statx'), | ||
| "st_birthtime and statx() not available or supported by Python on this OS") | ||
| # @support.requires_resource('walltime') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary, to run tests once on CI.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The code using os.statx() is correct. Don't forget to uncomment # @support.requires_resource('walltime').
| # Use stx_btime whenever it is available or use stx_ctime | ||
| # instead otherwise | ||
| creation_time = statx_result.stx_btime | ||
| if creation_time is None: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, stx_btime can be None. For example, on a tmpfs filesystem, on Linux 5.17 and older: #83714 (comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters