mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
GH-128520: pathlib ABCs: validate magic_open()
arguments (#131617)
When `pathlib._os.magic_open()` is called to open a path in binary mode, raise `ValueError` if any of the *encoding*, *errors* or *newline* arguments are given. This matches the `open()` built-in.
This commit is contained in:
parent
fbfb0e1f6e
commit
d716ea34cb
3 changed files with 12 additions and 0 deletions
|
@ -41,6 +41,9 @@ class WriteTestBase:
|
|||
#self.assertIsInstance(f, io.BufferedWriter)
|
||||
f.write(b'this is file A\n')
|
||||
self.assertEqual(self.ground.readbytes(p), b'this is file A\n')
|
||||
self.assertRaises(ValueError, magic_open, p, 'wb', encoding='utf8')
|
||||
self.assertRaises(ValueError, magic_open, p, 'wb', errors='strict')
|
||||
self.assertRaises(ValueError, magic_open, p, 'wb', newline='')
|
||||
|
||||
def test_write_bytes(self):
|
||||
p = self.root / 'fileA'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue