Replace stat.ST_xxx usage with os.stat().st_xxx (#116501)

Modernize code to use the new API which avoids the usage of the stat
module just to read os.stat() members.

* Sort logging.handlers imports.
* Rework reopenIfNeeded() code to make it easier to follow.
* Replace "not self.stream" with "self.stream is None".
This commit is contained in:
Victor Stinner 2024-03-08 18:49:09 +01:00 committed by GitHub
parent cca30230d9
commit 61831585b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 41 additions and 28 deletions

View file

@ -702,8 +702,7 @@ class TestMaildir(TestMailbox, unittest.TestCase):
self.assertEqual(self._box._factory, factory)
for subdir in '', 'tmp', 'new', 'cur':
path = os.path.join(self._path, subdir)
mode = os.stat(path)[stat.ST_MODE]
self.assertTrue(stat.S_ISDIR(mode), "Not a directory: '%s'" % path)
self.assertTrue(os.path.isdir(path), f"Not a directory: {path!r}")
def test_list_folders(self):
# List folders