Message86274
The documented behavior of io.BufferedReader.peek([n]) states:
peek([n])
Return 1 (or n if specified) bytes from a buffer without advancing the
position.
Thereas the parameter n is the _max_ length of returned bytes.
Implementation is:
def _peek_unlocked(self, n=0):
want = min(n, self.buffer_size)
have = len(self._read_buf) - self._read_pos
if have < want:
to_read = self.buffer_size - have
current = self.raw.read(to_read)
if current:
self._read_buf = self._read_buf[self._read_pos:] +
current
self._read_pos = 0
return self._read_buf[self._read_pos:]
Where you may see that the parameter n is the _min_ length
of returned bytes. So peek(1) will return _not_ just 1 Byte, but the
remaining bytes in the buffer. |
|
Date |
User |
Action |
Args |
2009-04-22 06:15:55 | trott | set | recipients:
+ trott |
2009-04-22 06:15:53 | trott | set | messageid: <1240380953.7.0.732520909261.issue5811@psf.upfronthosting.co.za> |
2009-04-22 06:15:51 | trott | link | issue5811 messages |
2009-04-22 06:15:48 | trott | create | |
|