Re: fileno support is not in jython. Reason?
Philip Jenvey <pjenvey <at> groovie.org>
2007-11-13 07:35:07 GMT
On Nov 12, 2007, at 3:20 AM, Alan Kennedy wrote:
>> PyFile (and PyFile nio) can also be backed by a Writer, which doesn't
>> have a corresponding Channel.
> As you're aware, java.io.Writer's are used for writing character
> streams, rather than byte streams. Since a character can be
> represented by multiple bytes, depending on character encoding, this
> is a non-trivial issue, as you know. Better layering would mean that
> PyFile would only be responsible for writing bytes, rather than
> characters. But I can see that a constructor for PyFile that takes a
> Writer has been included presumably for coding convenience, e.g. for
> use with character terminals such as the command line. (It is
> interesting to note that PEP 3116 attempts to layer I/O correctly,
> with byte oriented Raw IO, Buffered I/O and then text oriented
> Character I/O on top of all that, which is the right way, IMHO. But
> more on that later).
> What I am confused about is that there are no PyFile constructors that
> take java.io.Readers? If those constructors are there for the purpose
> of wrapping PyFiles around, e.g. character terminals, then there
> should be a constructor that takes a Reader, which would supply
> buffers full of chars to the interpreter, as the user typed them in?
> But my expectation is obviously wrong, there is no such constructor.
> So is user input decoded from the sys.defaultencoding?
Yea, the lack of an accompanying PyFile(Reader) is odd. As I said in
an earlier email, AFAICT the only reason for PyFile(Writer) is to