mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #13848: open() and the FileIO constructor now check for NUL characters in the file name.
Patch by Hynek Schlawack.
This commit is contained in:
commit
7ab4af0427
6 changed files with 41 additions and 21 deletions
|
|
@ -363,6 +363,11 @@ class IOTest(unittest.TestCase):
|
|||
self.assertRaises(exc, fp.seek, 1, self.SEEK_CUR)
|
||||
self.assertRaises(exc, fp.seek, -1, self.SEEK_END)
|
||||
|
||||
def test_open_handles_NUL_chars(self):
|
||||
fn_with_NUL = 'foo\0bar'
|
||||
self.assertRaises(TypeError, self.open, fn_with_NUL, 'w')
|
||||
self.assertRaises(TypeError, self.open, bytes(fn_with_NUL, 'ascii'), 'w')
|
||||
|
||||
def test_raw_file_io(self):
|
||||
with self.open(support.TESTFN, "wb", buffering=0) as f:
|
||||
self.assertEqual(f.readable(), False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue