summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-02 10:58:00 (GMT)
committerGitHub <noreply@github.com>2021-09-02 10:58:00 (GMT)
commit19ba2122ac7313ac29207360cfa864a275b9489e (patch)
treeab34611e2b6158889cabec93f76f40c71b6ea470 /Lib/test/test_io.py
parenta8066087054417885db0a2dbdce2ddb2ac498247 (diff)
downloadcpython-19ba2122ac7313ac29207360cfa864a275b9489e.zip
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.gz
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.bz2
bpo-37330: open() no longer accept 'U' in file mode (GH-28118)
open(), io.open(), codecs.open() and fileinput.FileInput no longer accept "U" ("universal newline") in the file mode. This flag was deprecated since Python 3.3.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 273545a..d52f97b 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3954,16 +3954,6 @@ class MiscIOTest(unittest.TestCase):
self.assertEqual(f.mode, "wb")
f.close()
- with warnings_helper.check_warnings(('', DeprecationWarning)):
- f = self.open(os_helper.TESTFN, "U", encoding="utf-8")
- self.assertEqual(f.name, os_helper.TESTFN)
- self.assertEqual(f.buffer.name, os_helper.TESTFN)
- self.assertEqual(f.buffer.raw.name, os_helper.TESTFN)
- self.assertEqual(f.mode, "U")
- self.assertEqual(f.buffer.mode, "rb")
- self.assertEqual(f.buffer.raw.mode, "rb")
- f.close()
-
f = self.open(os_helper.TESTFN, "w+", encoding="utf-8")
self.assertEqual(f.mode, "w+")
self.assertEqual(f.buffer.mode, "rb+") # Does it really matter?
@@ -3977,6 +3967,13 @@ class MiscIOTest(unittest.TestCase):
f.close()
g.close()
+ def test_removed_u_mode(self):
+ # bpo-37330: The "U" mode has been removed in Python 3.11
+ for mode in ("U", "rU", "r+U"):
+ with self.assertRaises(ValueError) as cm:
+ self.open(os_helper.TESTFN, mode)
+ self.assertIn('invalid mode', str(cm.exception))
+
def test_open_pipe_with_append(self):
# bpo-27805: Ignore ESPIPE from lseek() in open().
r, w = os.pipe()