New submission from David Wilson <[email protected]>:
Given:
$ cat tty-failure.py
import pty
import os
master, slave = pty.openpty()
master = os.fdopen(master, 'r+b', 0)
slave = os.fdopen(slave, 'r+b', 0)
slave.write(b'foo')
slave.close()
print(master.read())
On Python 2, read() would return b'foo', with subsequent calls raising IOError,
whereas on Python 3 an OSError is raised due to the underlying file descriptor
returning EIO.
In the case of a PTY, EIO indicates the remote side has hung up and more or
less can be treated as an EOF indicator.
On Python 3 the partial buffer should not be discarded when a subsequent read()
syscall returns an error.
Secondarily, the change from IOError to OSError looks wrong. Does anyone know
what's going on there? I would never expect to see OSError raised by a builtin
----------
components: IO
messages: 348578
nosy: dw
priority: normal
severity: normal
status: open
title: FileIO.read() on a closed TTY throws an exception prematurely
type: behavior
versions: Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37696>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com