diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-29 20:07:28 -0400 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-29 20:07:28 -0400 |
commit | b46526728f13e548ee7cef8b2c0510efbbb57da3 (patch) | |
tree | 0caeff5877c1c753ed84b584391a661324c62875 /Lib | |
parent | e12e78138790ee7ffc21687c65e3983a8893f7c0 (diff) | |
download | cpython-b46526728f13e548ee7cef8b2c0510efbbb57da3.tar.gz |
Issue #21679: Prevent extraneous fstat() calls during open(). Patch by Bohuslav Kabrda.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_fileio.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index c37482ed70..b87dc07805 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -60,6 +60,15 @@ class AutoFileTests(unittest.TestCase): self.assertRaises((AttributeError, TypeError), setattr, f, attr, 'oops') + def testBlksize(self): + # test private _blksize attribute + blksize = io.DEFAULT_BUFFER_SIZE + # try to get preferred blksize from stat.st_blksize, if available + if hasattr(os, 'fstat'): + fst = os.fstat(self.f.fileno()) + blksize = getattr(fst, 'st_blksize', blksize) + self.assertEqual(self.f._blksize, blksize) + def testReadinto(self): # verify readinto self.f.write(bytes([1, 2])) @@ -141,7 +150,7 @@ class AutoFileTests(unittest.TestCase): def testOpendir(self): # Issue 3703: opening a directory should fill the errno # Windows always returns "[Errno 13]: Permission denied - # Unix calls dircheck() and returns "[Errno 21]: Is a directory" + # Unix uses fstat and returns "[Errno 21]: Is a directory" try: _FileIO('.', 'r') except OSError as e: |