homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients christian.heimes
Date 2007年11月11日.17:26:35
SpamBayes Score 0.015548585
Marked as misclassified No
Message-id <1194801996.44.0.296899248876.issue1422@psf.upfronthosting.co.za>
In-reply-to
Content
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;
 }
History
Date User Action Args
2007年11月11日 17:26:36christian.heimessetspambayes_score: 0.0155486 -> 0.015548585
recipients: + christian.heimes
2007年11月11日 17:26:36christian.heimessetspambayes_score: 0.0155486 -> 0.0155486
messageid: <1194801996.44.0.296899248876.issue1422@psf.upfronthosting.co.za>
2007年11月11日 17:26:36christian.heimeslinkissue1422 messages
2007年11月11日 17:26:35christian.heimescreate

AltStyle によって変換されたページ (->オリジナル) /