MCPcopy Index your code
hub / github.com/RustPython/RustPython / write

Method write

Lib/_pyio.py:937–954  ·  view source on GitHub ↗
(self, b)

Source from the content-addressed store, hash-verified

935 return self.read(size)
936
937 def write(self, b):
938 if isinstance(b, str):
939 raise TypeError("can't write str to binary stream")
940 with memoryview(b) as view:
941 if self.closed:
942 raise ValueError("write to closed file")
943
944 n = view.nbytes # Size of any bytes-like object
945 if n == 0:
946 return 0
947
948 pos = self._pos
949 if pos > len(self._buffer):
950 # Pad buffer to pos with null bytes.
951 self._buffer.resize(pos)
952 self._buffer[pos:pos + n] = view
953 self._pos += n
954 return n
955
956 def seek(self, pos, whence=0):
957 if self.closed:

Callers 15

optimizeFunction · 0.95
get_messageMethod · 0.95
get_bytesMethod · 0.95
_safe_readMethod · 0.95
list_directoryMethod · 0.95
check_flush_and_readMethod · 0.95
test_writestrMethod · 0.95

Calls 3

isinstanceFunction · 0.85
lenFunction · 0.85
resizeMethod · 0.45

Tested by 13

check_flush_and_readMethod · 0.76
test_writestrMethod · 0.76
test_writeMethod · 0.76
test_open_writeMethod · 0.76
construct_zoneMethod · 0.76
zone_from_tzstrMethod · 0.76
test_01Function · 0.76