#5723 defect new
LogFile.rotate is overly careful in its LBYL code
|Reported by:||exarkun||Owned by:||mriehl|
(github, coverage, patch, buildbot, log)
if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return
Write access to a file is not necessary to rename that file. The second part of this check is superfluous and sometimes counterproductive (as the process may have write permission to the directory but not the file). It should be removed.
Additionally, look-before-you-leap is a bad way to write software. Instead, the code should probably just try rotating the file. If it fails with a permission error, that can be silenced.
This may have some relationship with #4707 as well.