New submission from Christian Heimes: The bug is related to http://bugs.python.org/issue1415 and occurs only with the latest patch from #1415.
Writing to an invalid fd doesn't raise an exception: >>> f = open(100, 'w') >>> f.fileno() 100 >>> f.write("test") 4 However reading or opening an invalid fd for reading and writing raises an exception. >>> f = open(100, 'r') >>> f.read() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/heimes/dev/python/py3k/Lib/io.py", line 1253, in read res += decoder.decode(self.buffer.read(), True) File "/home/heimes/dev/python/py3k/Lib/io.py", line 756, in read current = self.raw.read(to_read) IOError: [Errno 9] Bad file descriptor >>> f = open(100, 'w+') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/heimes/dev/python/py3k/Lib/io.py", line 195, in __new__ return open(*args, **kwargs) File "/home/heimes/dev/python/py3k/Lib/io.py", line 169, in open buffer = BufferedRandom(raw, buffering) File "/home/heimes/dev/python/py3k/Lib/io.py", line 948, in __init__ raw._checkSeekable() File "/home/heimes/dev/python/py3k/Lib/io.py", line 301, in _checkSeekable if msg is None else msg) IOError: File or stream is not seekable. I expected that fileio_write() raises an exception when fd is invalid: n = write(self->fd, ptr, n); if (n < 0) { if (errno == EAGAIN) Py_RETURN_NONE; PyErr_SetFromErrno(PyExc_IOError); return NULL; } ---------- assignee: tiran components: Interpreter Core keywords: py3k messages: 57372 nosy: tiran priority: normal severity: normal status: open title: Writing to an invalid fd doesn't raise an exception type: behavior versions: Python 3.0 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1422> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com