Skip to content

Commit 94f507d

Browse files
committed
add _MemoryFile.readinto method
1 parent 526438d commit 94f507d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/memoryfs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ def readable(self):
142142
# type: () -> bool
143143
return self._mode.reading
144144

145+
def readinto(self, b):
146+
# type (bytes) -> Optional[int]
147+
if not self._mode.reading:
148+
raise IOError("File not open for reading")
149+
with self._seek_lock():
150+
self.on_access()
151+
return self._bytes_io.readinto(b)
152+
145153
def readlines(self, hint=-1):
146154
# type: (int) -> List[bytes]
147155
with self._seek_lock():

0 commit comments

Comments
 (0)