(self, obj)
| 823 | |
| 824 | if _HAVE_PICKLE_BUFFER: |
| 825 | def save_picklebuffer(self, obj): |
| 826 | if self.proto < 5: |
| 827 | raise PicklingError("PickleBuffer can only pickled with " |
| 828 | "protocol >= 5") |
| 829 | with obj.raw() as m: |
| 830 | if not m.contiguous: |
| 831 | raise PicklingError("PickleBuffer can not be pickled when " |
| 832 | "pointing to a non-contiguous buffer") |
| 833 | in_band = True |
| 834 | if self._buffer_callback is not None: |
| 835 | in_band = bool(self._buffer_callback(obj)) |
| 836 | if in_band: |
| 837 | # Write data in-band |
| 838 | # XXX The C implementation avoids a copy here |
| 839 | if m.readonly: |
| 840 | self.save_bytes(m.tobytes()) |
| 841 | else: |
| 842 | self.save_bytearray(m.tobytes()) |
| 843 | else: |
| 844 | # Write data out-of-band |
| 845 | self.write(NEXT_BUFFER) |
| 846 | if m.readonly: |
| 847 | self.write(READONLY_BUFFER) |
| 848 | |
| 849 | dispatch[PickleBuffer] = save_picklebuffer |
| 850 |
nothing calls this directly
no test coverage detected