mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39674: Revert "bpo-37330: open() no longer accept 'U' in file mode (GH-16959)" (GH-18767)
This reverts commit e471e72977
.
The mode will be removed from Python 3.10.
This commit is contained in:
parent
00c77ae55a
commit
942f7a2dea
13 changed files with 99 additions and 54 deletions
|
@ -3900,6 +3900,16 @@ class MiscIOTest(unittest.TestCase):
|
|||
self.assertEqual(f.mode, "wb")
|
||||
f.close()
|
||||
|
||||
with support.check_warnings(('', DeprecationWarning)):
|
||||
f = self.open(support.TESTFN, "U")
|
||||
self.assertEqual(f.name, support.TESTFN)
|
||||
self.assertEqual(f.buffer.name, support.TESTFN)
|
||||
self.assertEqual(f.buffer.raw.name, support.TESTFN)
|
||||
self.assertEqual(f.mode, "U")
|
||||
self.assertEqual(f.buffer.mode, "rb")
|
||||
self.assertEqual(f.buffer.raw.mode, "rb")
|
||||
f.close()
|
||||
|
||||
f = self.open(support.TESTFN, "w+")
|
||||
self.assertEqual(f.mode, "w+")
|
||||
self.assertEqual(f.buffer.mode, "rb+") # Does it really matter?
|
||||
|
@ -3913,13 +3923,6 @@ class MiscIOTest(unittest.TestCase):
|
|||
f.close()
|
||||
g.close()
|
||||
|
||||
def test_removed_u_mode(self):
|
||||
# "U" mode has been removed in Python 3.9
|
||||
for mode in ("U", "rU", "r+U"):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
self.open(support.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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue