I want to use a buffered stream because I want to use a peek()
method to peek ahead but use my stream with another method that expects a file-like object. (I'd use seek()
but may have to handle piped-in I/O that doesn't support random access.)
But this test case fails:
AttributeError: 'file' object has no attribute '_checkReadable'
import sys
import io
srcfile = sys.argv[1]
with open(srcfile, 'rb') as f:
fbuf = io.BufferedReader(f)
print fbuf.read(20)
What's going on and how do I fix it? I thought BufferedReader was intended to buffer a stream. If so, why does the open()
function not return something that's compatible with it?
_checkReadable
as well, while my 2.7.2 complains aboutreadable
. I can't find the commit right now, but this was probably changed this somewhere between 2.7.0 and 2.7.2. – Naturalistic