[New-bugs-announce] [issue41352] FileIO.readall() should raise "UnsupportedOperation" when in "w" mode
Ziyi Wang
report at bugs.python.org
Mon Jul 20 17:14:00 EDT 2020
New submission from Ziyi Wang <evnw at fb.com>:
Here are the two test cases: the one with FileIO.readall() fails
def testReadWithWritingMode(self):
r, w = os.pipe()
w = os.fdopen(w, "w")
w.write("hello")
w.close()
with io.FileIO(r, mode="w") as f:
with self.assertRaises(_io.UnsupportedOperation):
f.read()
def testReadallWithWritingMode(self):
r, w = os.pipe()
w = os.fdopen(w, "w")
w.write("hello")
w.close()
with io.FileIO(r, mode="w") as f:
with self.assertRaises(_io.UnsupportedOperation):
f.readall()
With FileIO.read() raises "UnsupportedOperation" in "w" mode, I expect FileIO.readall() do the same. But in fact FileIO.readall() does not check for readable and does not raise "UnsupportedOperation" in "w"mode.
I'm happy to write a pull request if you want.
----------
components: IO, Library (Lib)
messages: 374027
nosy: Ziyi Wang
priority: normal
severity: normal
status: open
title: FileIO.readall() should raise "UnsupportedOperation" when in "w" mode
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41352>
_______________________________________
More information about the New-bugs-announce
mailing list