We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c879cdf commit ef214e3Copy full SHA for ef214e3
Lib/_pyio.py
@@ -937,10 +937,8 @@ def write(self, b):
937
return 0
938
pos = self._pos
939
if pos > len(self._buffer):
940
- # Inserts null bytes between the current end of the file
941
- # and the new write position.
942
- padding = b'\x00' * (pos - len(self._buffer))
943
- self._buffer += padding
+ # Pad buffer to pos with null bytes.
+ self._buffer.resize(pos)
944
self._buffer[pos:pos + n] = b
945
self._pos += n
946
return n
0 commit comments