New submission from Ziyi Wang <e...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue41352> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com