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 Ziyi Wang
Recipients Ziyi Wang
Date 2020-07-20.21:14:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595279640.58.0.284092405556.issue41352@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-07-20 21:14:00Ziyi Wangsetrecipients: + Ziyi Wang
2020-07-20 21:14:00Ziyi Wangsetmessageid: <1595279640.58.0.284092405556.issue41352@roundup.psfhosted.org>
2020-07-20 21:14:00Ziyi Wanglinkissue41352 messages
2020-07-20 21:14:00Ziyi Wangcreate