[Python-Dev] py34 makes it harder to read all of a pty

2014-11-12 Thread Buck Golemon
This code works as expected in python <3.4 (printing 'ok' then an error),
but only gives an error in python3.4.

```
import os
read_fd, write_fd = os.openpty()
os.write(write_fd, b'ok\n')
os.close(write_fd)

read_file = os.fdopen(read_fd, 'rb', 0)
print("read: %r" % read_file.read())
print("read: %r" % read_file.read())
```

This is due to the fix for issue21090 ,
which aimed to un-silence errors which previously went unheard. The fix is
for me, as a user, to write a loop that uses os.read and interpretes EIO as
EOF. This is what I had hoped file.read() would do for me, however, and
what it used to do in previous pythons.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] py34 makes it harder to read all of a pty

2014-11-12 Thread Charles-François Natali
2014-11-12 22:16 GMT+00:00 Buck Golemon :
> This is due to the fix for issue21090, which aimed to un-silence errors
> which previously went unheard. The fix is for me, as a user, to write a loop
> that uses os.read and interpretes EIO as EOF. This is what I had hoped
> file.read() would do for me, however, and what it used to do in previous
> pythons.


There's no reason for read() to interpret EIO as EOF in the general
case: it was masked in previous versions because of a mere bug. The
behavior is now correct, although being able to retrieve the data read
so far in case of a buffered read could be useful.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com