Skip to content

Commit acef240

Browse files
committed
add _MemoryFile.readinto method
1 parent 6fc6ac5 commit acef240

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
@@ -137,6 +137,14 @@ def readable(self):
137137
# type: () -> bool
138138
return self._mode.reading
139139

140+
def readinto(self, b):
141+
# type (bytes) -> Optional[int]
142+
if not self._mode.reading:
143+
raise IOError("File not open for reading")
144+
with self._seek_lock():
145+
self.on_access()
146+
return self._bytes_io.readinto(b)
147+
140148
def readlines(self, hint=-1):
141149
# type: (int) -> List[bytes]
142150
with self._seek_lock():

0 commit comments

Comments
 (0)