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

Method write

Lib/_pyio.py:1732–1744  ·  view source on GitHub ↗

Write bytes b to file, return number written. Only makes one system call, so not all of the data may be written. The number of bytes actually written is returned. In non-blocking mode, returns None if the write would block.

(self, b)

Source from the content-addressed store, hash-verified

1730 return None
1731
1732 def write(self, b):
1733 """Write bytes b to file, return number written.
1734
1735 Only makes one system call, so not all of the data may be written.
1736 The number of bytes actually written is returned. In non-blocking mode,
1737 returns None if the write would block.
1738 """
1739 self._checkClosed()
1740 self._checkWritable()
1741 try:
1742 return os.write(self._fd, b)
1743 except BlockingIOError:
1744 return None
1745
1746 def seek(self, pos, whence=SEEK_SET):
1747 """Move to new file position.

Callers 12

testBytesOpenMethod · 0.95
testUtf8BytesOpenMethod · 0.95
testTruncateMethod · 0.95
bug801631Method · 0.95
testAppendMethod · 0.95
writelinesMethod · 0.45
_flush_unlockedMethod · 0.45
writeMethod · 0.45
writeMethod · 0.45
writeMethod · 0.45
__init__Method · 0.45

Calls 2

_checkWritableMethod · 0.95
_checkClosedMethod · 0.45

Tested by 6

testBytesOpenMethod · 0.76
testUtf8BytesOpenMethod · 0.76
testTruncateMethod · 0.76
bug801631Method · 0.76
testAppendMethod · 0.76