mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +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
|
@ -712,23 +712,11 @@ class UTF16Test(ReadTest, unittest.TestCase):
|
|||
self.addCleanup(support.unlink, support.TESTFN)
|
||||
with open(support.TESTFN, 'wb') as fp:
|
||||
fp.write(s)
|
||||
with codecs.open(support.TESTFN, 'r',
|
||||
encoding=self.encoding) as reader:
|
||||
with support.check_warnings(('', DeprecationWarning)):
|
||||
reader = codecs.open(support.TESTFN, 'U', encoding=self.encoding)
|
||||
with reader:
|
||||
self.assertEqual(reader.read(), s1)
|
||||
|
||||
def test_invalid_modes(self):
|
||||
for mode in ('U', 'rU', 'r+U'):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
codecs.open(support.TESTFN, mode, encoding=self.encoding)
|
||||
self.assertIn('invalid mode', str(cm.exception))
|
||||
|
||||
for mode in ('rt', 'wt', 'at', 'r+t'):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
codecs.open(support.TESTFN, mode, encoding=self.encoding)
|
||||
self.assertIn("can't have text and binary mode at once",
|
||||
str(cm.exception))
|
||||
|
||||
|
||||
class UTF16LETest(ReadTest, unittest.TestCase):
|
||||
encoding = "utf-16-le"
|
||||
ill_formed_sequence = b"\x80\xdc"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue