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:
Antoine Pitrou 2012-01-29 18:36:34 +01:00
parent c875d2032b
commit 1334884ff2
7 changed files with 44 additions and 22 deletions

View file

@ -305,6 +305,11 @@ class OtherFileTests(unittest.TestCase):
finally:
os.unlink(TESTFN)
def testConstructorHandlesNULChars(self):
fn_with_NUL = 'foo\0bar'
self.assertRaises(TypeError, _FileIO, fn_with_NUL, 'w')
self.assertRaises(TypeError, _FileIO, bytes(fn_with_NUL, 'ascii'), 'w')
def testInvalidFd(self):
self.assertRaises(ValueError, _FileIO, -10)
self.assertRaises(OSError, _FileIO, make_bad_fd())