gh-101819: Isolate _io (#101948)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Erlend E. Aasland 2023-05-15 11:26:27 +02:00 committed by GitHub
parent 35bf0916d9
commit 186bf39f5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 208 additions and 365 deletions

View file

@ -4242,6 +4242,7 @@ class MiscIOTest(unittest.TestCase):
def test_pickling(self):
# Pickling file objects is forbidden
msg = "cannot pickle"
for kwargs in [
{"mode": "w"},
{"mode": "wb"},
@ -4256,8 +4257,10 @@ class MiscIOTest(unittest.TestCase):
if "b" not in kwargs["mode"]:
kwargs["encoding"] = "utf-8"
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
with self.open(os_helper.TESTFN, **kwargs) as f:
self.assertRaises(TypeError, pickle.dumps, f, protocol)
with self.subTest(protocol=protocol, kwargs=kwargs):
with self.open(os_helper.TESTFN, **kwargs) as f:
with self.assertRaisesRegex(TypeError, msg):
pickle.dumps(f, protocol)
@unittest.skipIf(
support.is_emscripten, "fstat() of a pipe fd is not supported"