[Python-ideas] BufferedIO and detach

Robert Collins robertc at robertcollins.net
Mon Mar 4 03:31:00 CET 2013

On 4 March 2013 05:16, Benjamin Peterson <benjamin at python.org> wrote:
> Robert Collins <robertc at ...> writes:
>> There doesn't seem to be a way to safely use detach() on stdin - I'd
>> like to get down to the raw stream, but after calling detach(), the
>> initial BufferedIOReader is unusable - so you cannot retrieve any
>> buffered content) - and unless you detach(), you can't guarantee that
>> the buffer will ever be empty.
> Presumably if you call it before anyone else has had a chance to read from it,
> you should be okay.

Thats hard to guarantee in the general case: consider a library
utility that accepts an input stream. To make it concrete, consider
dispatching to different processors based on the first few bytes of a
stream: you'd have to force raw IO handling everywhere, rather than
just the portion of code that needs it...


Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Cloud Services

More information about the Python-ideas mailing list