MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / read

Method read

tools/python-3.11.9-amd64/Lib/_pyio.py:2528–2555  ·  view source on GitHub ↗
(self, size=None)

Source from the content-addressed store, hash-verified

2526 return cookie
2527
2528 def read(self, size=None):
2529 self._checkReadable()
2530 if size is None:
2531 size = -1
2532 else:
2533 try:
2534 size_index = size.__index__
2535 except AttributeError:
2536 raise TypeError(f"{size!r} is not an integer")
2537 else:
2538 size = size_index()
2539 decoder = self._decoder or self._get_decoder()
2540 if size < 0:
2541 # Read everything.
2542 result = (self._get_decoded_chars() +
2543 decoder.decode(self.buffer.read(), final=True))
2544 if self._snapshot is not None:
2545 self._set_decoded_chars('')
2546 self._snapshot = None
2547 return result
2548 else:
2549 # Keep reading chunks until we have size characters to return.
2550 eof = False
2551 result = self._get_decoded_chars(size)
2552 while len(result) < size and not eof:
2553 eof = not self._read_chunk()
2554 result += self._get_decoded_chars(size - len(result))
2555 return result
2556
2557 def __next__(self):
2558 self._telling = False

Callers 1

test_non_asciiMethod · 0.95

Calls 7

_get_decoderMethod · 0.95
_get_decoded_charsMethod · 0.95
_set_decoded_charsMethod · 0.95
_read_chunkMethod · 0.95
_checkReadableMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by 1

test_non_asciiMethod · 0.76