Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rmmancom committed Jun 18, 2024
1 parent 0839fb6 commit 3abce4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ def __init__(self, file, mode='r', closefd=True, opener=None):
# don't exist.
pass
self._blksize = getattr(fdfstat, 'st_blksize', 0)
if self._blksize <= 1:
if self._blksize <= DEFAULT_BUFFER_SIZE:
self._blksize = DEFAULT_BUFFER_SIZE

if _setmode:
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ def testAttributes(self):
self.assertRaises((AttributeError, TypeError),
setattr, f, attr, 'oops')

@unittest.skipIf(is_wasi, "WASI does not expose st_blksize.")
def testBlksize(self):
# test private _blksize attribute
blksize = io.DEFAULT_BUFFER_SIZE
blksize = 0
# 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)
if blksize < io.DEFAULT_BUFFER_SIZE:
blksize = io.DEFAULT_BUFFER_SIZE
self.assertEqual(self.f._blksize, blksize)

# verify readinto
Expand Down

0 comments on commit 3abce4a

Please sign in to comment.