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

Method _safe_read

tools/python-3.11.9-amd64/Lib/http/client.py:631–641  ·  view source on GitHub ↗

Read the number of bytes requested. This function should be used when bytes "should" be present for reading. If the bytes are truly not available (due to EOF), then the IncompleteRead exception can be used to detect the problem.

(self, amt)

Source from the content-addressed store, hash-verified

629 raise IncompleteRead(bytes(b[0:total_bytes]))
630
631 def _safe_read(self, amt):
632 """Read the number of bytes requested.
633
634 This function should be used when <amt> bytes "should" be present for
635 reading. If the bytes are truly not available (due to EOF), then the
636 IncompleteRead exception can be used to detect the problem.
637 """
638 data = self.fp.read(amt)
639 if len(data) < amt:
640 raise IncompleteRead(data, amt-len(data))
641 return data
642
643 def _safe_readinto(self, b):
644 """Same as _safe_read, but for reading into a buffer."""

Callers 3

readMethod · 0.95
_get_chunk_leftMethod · 0.95
_read_chunkedMethod · 0.95

Calls 2

IncompleteReadClass · 0.70
readMethod · 0.45

Tested by

no test coverage detected