| 319 | return self._buffer.write(data) |
| 320 | |
| 321 | def _write_raw(self, data): |
| 322 | # Called by our self._buffer underlying WriteBufferStream. |
| 323 | if isinstance(data, (bytes, bytearray)): |
| 324 | length = len(data) |
| 325 | else: |
| 326 | # accept any data that supports the buffer protocol |
| 327 | data = memoryview(data) |
| 328 | length = data.nbytes |
| 329 | |
| 330 | if length > 0: |
| 331 | self.fileobj.write(self.compress.compress(data)) |
| 332 | self.size += length |
| 333 | self.crc = zlib.crc32(data, self.crc) |
| 334 | self.offset += length |
| 335 | |
| 336 | return length |
| 337 | |
| 338 | def _check_read(self, caller): |
| 339 | if self.mode != READ: |