Dolda2000
2013-12-26 20:01:49 UTC
New submission from Dolda2000:
It seems open() is slightly broken in Python 3, in that one cannot open non-seekable files in read-write mode. One such common use is open("/dev/tty", "r+") for interacting directly with the controlling TTY regardless of standard stream redirections. Note that this is a regression for Python 2, where this worked as expected.
File "<stdin>", line 1, in <module>
io.UnsupportedOperation: File or stream is not seekable.
Just for the record, the same thing happens with "w+" and "rb+".
This also means that the getpass module is slightly broken, since it will always fail whenever stdin is redirected.
----------
components: IO
messages: 206957
nosy: Dolda2000
priority: normal
severity: normal
status: open
title: open() of read-write non-seekable streams broken
type: behavior
versions: Python 3.1, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20074>
_______________________________________
It seems open() is slightly broken in Python 3, in that one cannot open non-seekable files in read-write mode. One such common use is open("/dev/tty", "r+") for interacting directly with the controlling TTY regardless of standard stream redirections. Note that this is a regression for Python 2, where this worked as expected.
open("/dev/tty", "r+")
Traceback (most recent call last):File "<stdin>", line 1, in <module>
io.UnsupportedOperation: File or stream is not seekable.
Just for the record, the same thing happens with "w+" and "rb+".
This also means that the getpass module is slightly broken, since it will always fail whenever stdin is redirected.
----------
components: IO
messages: 206957
nosy: Dolda2000
priority: normal
severity: normal
status: open
title: open() of read-write non-seekable streams broken
type: behavior
versions: Python 3.1, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20074>
_______________________________________