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)
| 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.""" |
no test coverage detected