Nick Coghlan <ncoghlan <at> gmail.com> writes:
> 
> Since the latter method will perform as many reads of the underlying
> stream as necessary to reach the requested number of bytes (or EOF),
> then so should the former.

How do you propose to implement this while staying compatible with
1) unseekable raw streams
2) the expectation that peek() doesn't advance the logical file pointer?

> Note that the current behaviour I get from Python 3.1 is for it to
> return the *entire* buffer, no matter what number I pass to it:
> 
[...]
> 
> That's an outright bug - I've promoted an existing issue about this [1]
> to a release blocker and sent it to Benjamin to have another look at.

The original docstring for peek() says:

        """Returns buffered bytes without advancing the position.

        The argument indicates a desired minimal number of bytes; we
        do at most one raw read to satisfy it.  We never return more
        than self.buffer_size.
        """

In that light, I'm not sure it's a bug -- although it can certainly look
unexpected at first sight.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to