MCPcopy Index your code
hub / github.com/RustPython/RustPython / read

Method read

Lib/_pyio.py:1655–1675  ·  view source on GitHub ↗

Read at most size bytes, returned as bytes. If size is less than 0, read all bytes in the file making multiple read calls. See ``FileIO.readall``. Attempts to make only one system call, retrying only per PEP 475 (EINTR). This means less data may be returned than

(self, size=None)

Source from the content-addressed store, hash-verified

1653 raise UnsupportedOperation('File not open for writing')
1654
1655 def read(self, size=None):
1656 """Read at most size bytes, returned as bytes.
1657
1658 If size is less than 0, read all bytes in the file making
1659 multiple read calls. See ``FileIO.readall``.
1660
1661 Attempts to make only one system call, retrying only per
1662 PEP 475 (EINTR). This means less data may be returned than
1663 requested.
1664
1665 In non-blocking mode, returns None if no data is available.
1666 Return an empty bytes object at EOF.
1667 """
1668 self._checkClosed()
1669 self._checkReadable()
1670 if size is None or size < 0:
1671 return self.readall()
1672 try:
1673 return os.read(self._fd, size)
1674 except BlockingIOError:
1675 return None
1676
1677 def readall(self):
1678 """Read all data from the file, returned as bytes.

Callers 13

testBytesOpenMethod · 0.95
testUtf8BytesOpenMethod · 0.95
bug801631Method · 0.95
testAppendMethod · 0.95
readlineMethod · 0.45
_read_unlockedMethod · 0.45
_peek_unlockedMethod · 0.45
readMethod · 0.45
readMethod · 0.45
_read_chunkMethod · 0.45
seekMethod · 0.45

Calls 3

_checkReadableMethod · 0.95
readallMethod · 0.95
_checkClosedMethod · 0.45

Tested by 5

testBytesOpenMethod · 0.76
testUtf8BytesOpenMethod · 0.76
bug801631Method · 0.76
testAppendMethod · 0.76