mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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:
parent
c875d2032b
commit
1334884ff2
7 changed files with 44 additions and 22 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