New submission from Torsten Rottmann tr...@meditec-gmbh.com:
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
Torsten Rottmann tr...@meditec-gmbh.com added the comment:
Note: this is also in Python 2.6
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5811
Torsten Rottmann tr...@meditec-gmbh.com added the comment:
Proposed patch to fix this:
set the default of n to 1 as stated by docs:
def _peek_unlocked(self, n=1):
return n bytes:
return self._read_buf[self._read_pos:self._read_pos+n
New submission from Torsten Rottmann [EMAIL PROTECTED]:
The attached file produced the following result:
__
trott$ python2.5 p6.py
[]
[1234]
__
I expected both times the empty list since the print
statement prints just a defaulted parameter (e) which
Torsten Rottmann [EMAIL PROTECTED] added the comment:
OK. I've read the Python Reference Manual 7.6 Function Definition.
It explains why this happens.
BUT: Why can`t the compiler make a copy of the default object, if
it's mutable (e.g. a list)? This can't be that difficult